2012-11-09 10:40:57 +00:00
|
|
|
{% extends "global/layout.html" %}
|
2009-05-06 19:46:57 +00:00
|
|
|
{% block title %}SAM V3{% endblock %}
|
2018-03-01 14:44:11 +00:00
|
|
|
{% block lastupdated %}March 2018{% endblock %}
|
|
|
|
{% block accuratefor %}0.9.34{% endblock %}
|
2009-05-06 19:46:57 +00:00
|
|
|
{% block content %}
|
|
|
|
<p>Specified below is a simple client protocol for interacting with I2P.
|
2010-08-16 01:55:25 +00:00
|
|
|
</p>
|
|
|
|
<p>SAM version 3
|
|
|
|
was introduced in I2P release 0.7.3.
|
|
|
|
Alternatives:
|
2012-11-09 10:40:57 +00:00
|
|
|
<a href="{{ site_url('docs/api/sam') }}">SAM V1</a>,
|
|
|
|
<a href="{{ site_url('docs/api/samv2') }}">SAM V2</a>,
|
|
|
|
<a href="{{ site_url('docs/api/bob') }}">BOB</a>.
|
2009-05-06 19:46:57 +00:00
|
|
|
</p>
|
|
|
|
|
2014-07-13 23:56:20 +00:00
|
|
|
<h2>Version 3 Language Libraries</h2>
|
|
|
|
<ul>
|
2017-04-01 12:35:30 +00:00
|
|
|
<li>C - <a href="https://github.com/i2p/libsam3">libsam3</a></li>
|
|
|
|
<li>C++ - <a href="https://github.com/i2p/i2psam">i2psam</a></li>
|
2014-07-13 23:56:20 +00:00
|
|
|
<li>Go - <a href="https://bitbucket.org/kallevedin/sam3">sam3</a>,
|
|
|
|
<a href="https://github.com/cryptix/goSam">goSam</a> (<a href="http://git.repo.i2p/w/goSam.git">in I2P</a>)</li>
|
2018-02-15 20:44:34 +00:00
|
|
|
<li>Nodejs - <a href="https://github.com/redhog/node-i2p">node-i2p</a></li>
|
2018-10-23 16:15:48 +00:00
|
|
|
<li>Python - <a href="https://github.com/l-n-s/i2plib">i2plib</a>,
|
|
|
|
<a href="https://github.com/majestrate/i2p.socket">i2p.socket</a>,
|
|
|
|
<a href="https://github.com/str4d/txi2p">txi2p</a></li>
|
2014-07-13 23:56:20 +00:00
|
|
|
</ul>
|
|
|
|
|
2014-06-28 15:56:00 +00:00
|
|
|
<h2>Version 3 Changes</h2>
|
|
|
|
<h3>Version 3.0 Changes</h3>
|
|
|
|
<p>
|
|
|
|
Version 3.0 was introduced in I2P release 0.7.3.
|
2010-08-16 01:55:25 +00:00
|
|
|
SAM v2 provided a way to manage several sockets
|
2009-05-06 19:46:57 +00:00
|
|
|
on the same I2P destination <i>in parallel</i>, i.e. the client does not
|
|
|
|
have to wait for data being successfully sent on one socket before sending
|
2010-08-16 01:55:25 +00:00
|
|
|
data on another socket. But all data transited through the same
|
|
|
|
client<-->SAM socket, which was quite complicated to manage for the client.
|
2009-05-06 19:46:57 +00:00
|
|
|
<p />
|
2010-08-16 01:55:25 +00:00
|
|
|
SAM v3 manages sockets in a different way: each <i>I2P socket</i>
|
|
|
|
matches a unique client<-->SAM socket, which is much more simple to handle.
|
2012-11-09 10:40:57 +00:00
|
|
|
This is similar to <a href="{{ site_url('docs/api/bob') }}">BOB</a>.
|
2009-05-06 19:46:57 +00:00
|
|
|
<br />
|
2010-08-16 01:55:25 +00:00
|
|
|
SAM v3 also offers a UDP port for sending datagrams through I2P, and
|
2009-05-06 19:46:57 +00:00
|
|
|
can forward back I2P datagrams to the client's datagram server.
|
2014-06-28 15:56:00 +00:00
|
|
|
</p>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2014-06-28 15:56:00 +00:00
|
|
|
<h3>Version 3.1 Changes</h3>
|
|
|
|
<p>
|
|
|
|
Version 3.1 was introduced in I2P release 0.9.14.
|
|
|
|
<ul>
|
|
|
|
<li>DEST GENERATE and SESSION CREATE now support a SIGNATURE_TYPE parameter.
|
|
|
|
<li>The MIN and MAX parameters in HELLO VERSION are now optional.
|
|
|
|
<li>The MIN and MAX parameters in HELLO VERSION now support single-digit versions such as "3".
|
2014-07-19 15:57:32 +00:00
|
|
|
<li>RAW SEND is now supported on the bridge socket.
|
2014-06-28 15:56:00 +00:00
|
|
|
</ul>
|
|
|
|
</p>
|
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
<h3>Version 3.2 Changes</h3>
|
2015-06-11 16:48:03 +00:00
|
|
|
<p>
|
2016-01-03 00:13:11 +00:00
|
|
|
Version 3.2 was introduced in I2P release 0.9.24.
|
2016-01-03 13:20:58 +00:00
|
|
|
</p>
|
|
|
|
|
|
|
|
<h4>I2CP Port and Protocol Support</h4>
|
2015-06-11 16:48:03 +00:00
|
|
|
<ul>
|
2016-01-03 13:20:58 +00:00
|
|
|
<li>SESSION CREATE options FROM_PORT and TO_PORT
|
|
|
|
<li>SESSION CREATE STYLE=RAW option PROTOCOL
|
|
|
|
<li>STREAM CONNECT, DATAGRAM SEND, and RAW SEND options FROM_PORT and TO_PORT
|
|
|
|
<li>RAW SEND option PROTOCOL
|
2015-11-27 18:25:52 +00:00
|
|
|
<li>DATAGRAM RECEIVED, RAW RECEIVED, and forwarded or received streams and repliable datagrams,
|
2016-01-03 13:20:58 +00:00
|
|
|
includes FROM_PORT and TO_PORT
|
|
|
|
<li>RAW session option HEADER=true will cause
|
|
|
|
the forwarded raw datagrams to be prepended with a line containing PROTOCOL=nnn FROM_PORT=nnnn TO_PORT=nnnn
|
2015-07-07 14:05:01 +00:00
|
|
|
<li>The first line of datagrams sent through port 7655 may now start with any 3.x version
|
2016-01-03 13:20:58 +00:00
|
|
|
<li>The first line of datagrams sent through port 7655 may contain
|
|
|
|
any of the options FROM_PORT, TO_PORT, PROTOCOL
|
|
|
|
<li>RAW RECEIVED includes PROTOCOL=nnn
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<h4>SSL and Authentication</h4>
|
|
|
|
<ul>
|
2016-02-10 15:01:13 +00:00
|
|
|
<li>USER/PASSWORD in the HELLO parameters for authorization. See <a href="#userpw">below</a>.
|
|
|
|
<li>Optional authorization configuration with the AUTH command. See <a href="#auth">below</a>.
|
|
|
|
<li>Optional SSL/TLS support on the control socket. See <a href="#ssl">below</a>.
|
2016-01-03 13:20:58 +00:00
|
|
|
<li>STREAM FORWARD option SSL=true
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<h4>Multithreading</h4>
|
|
|
|
<ul>
|
|
|
|
<li>Concurrent pending STREAM ACCEPTs are allowed on the same session ID.
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<h4>Command Line Parsing and Keepalive</h4>
|
|
|
|
<ul>
|
2016-02-10 15:01:13 +00:00
|
|
|
<li>Optional commands QUIT, STOP and EXIT to close the session and socket. See <a href="#quit">below</a>.
|
2015-11-28 21:42:00 +00:00
|
|
|
<li>Command parsing will properly handle UTF-8
|
|
|
|
<li>Command parsing reliably handles whitespace inside quotes
|
|
|
|
<li>A backslash '\' may escape quotes on the command line
|
2016-01-03 13:20:58 +00:00
|
|
|
<li>Recommended that the server map commands to upper case, for ease in testing via telnet.
|
2015-11-28 21:42:00 +00:00
|
|
|
<li>Empty option values such as PROTOCOL or PROTOCOL= may be allowed, implementation dependent.
|
2016-01-03 13:20:58 +00:00
|
|
|
<li>PING/PONG for keepalive. See below.
|
2015-11-28 21:42:00 +00:00
|
|
|
<li>Servers may implement timeouts for the HELLO or subsequent commands, implementation dependent.
|
2015-06-11 16:48:03 +00:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-10 15:01:13 +00:00
|
|
|
<h3>Version 3.3 Changes</h3>
|
2015-11-25 00:13:38 +00:00
|
|
|
<p>
|
2016-04-04 12:05:57 +00:00
|
|
|
Version 3.3 was introduced in I2P release 0.9.25.
|
2015-11-25 00:13:38 +00:00
|
|
|
<ul>
|
2016-02-06 19:31:23 +00:00
|
|
|
<li>The same session may be used for streams, datagrams, and raw simultaneously.
|
2015-11-25 00:13:38 +00:00
|
|
|
Incoming packets and streams will be routed based on I2P protocol and to-port.
|
2016-02-06 19:31:23 +00:00
|
|
|
See <a href="#master">the MASTER section below</a>.
|
2016-02-07 19:07:27 +00:00
|
|
|
<li>DATAGRAM SEND and RAW SEND now support options SEND_TAGS, TAG_THRESHOLD, EXPIRES, and SEND_LEASESET.
|
2016-02-10 15:01:13 +00:00
|
|
|
See <a href="#v3dgsend">the datagram sending section below</a>.
|
2015-11-25 00:13:38 +00:00
|
|
|
</ul>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-06-28 15:56:00 +00:00
|
|
|
<h2>Version 3 Protocol</h2>
|
2016-02-10 15:01:13 +00:00
|
|
|
<h3>Simple Anonymous Messaging (SAM) Version 3.3 Specification Overview</h3>
|
2015-05-12 14:24:36 +00:00
|
|
|
<p>
|
2016-02-06 20:05:06 +00:00
|
|
|
The client application talks to the SAM bridge, which deals with
|
2010-08-16 01:55:25 +00:00
|
|
|
all of the I2P functionality (using the streaming
|
2016-02-06 20:05:06 +00:00
|
|
|
library for virtual streams, or I2CP directly for datagrams).
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2016-02-06 20:05:06 +00:00
|
|
|
By default, the client<-->SAM bridge communication is unencrypted and unauthenticated.
|
2016-01-03 00:13:11 +00:00
|
|
|
The SAM bridge may support SSL/TLS connections;
|
|
|
|
configuration and implementation details are outside the scope of this specification.
|
2016-02-06 20:05:06 +00:00
|
|
|
As of SAM 3.2, optional authentication user/password parameters are supported in the initial handshake
|
2018-03-01 14:44:11 +00:00
|
|
|
and may be required by the bridge.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
|
|
|
I2P communications can take three distinct forms:
|
|
|
|
<ul><li>
|
|
|
|
<a href="{{ site_url('docs/api/streaming') }}">Virtual streams</a>
|
|
|
|
</lil><li>
|
|
|
|
<a href="{{ site_url('docs/spec/datagrams') }}#repliable">Repliable datagrams</a> (messages with a FROM field)
|
|
|
|
</lil><li>
|
|
|
|
<a href="{{ site_url('docs/spec/datagrams') }}#raw">Anonymous datagrams</a> (raw anonymous messages)
|
|
|
|
</lil></ul>
|
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
I2P communications are supported by I2P sessions, and each I2P
|
|
|
|
session is bound to an address (called destination). An I2P session
|
|
|
|
is associated with one of the three types above, and cannot carry
|
2016-02-06 20:05:06 +00:00
|
|
|
communications of another type,
|
|
|
|
unless using <a href="#master">MASTER sessions</a>.
|
2015-05-12 14:24:36 +00:00
|
|
|
</p>
|
2016-01-03 00:13:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
<h3>Encoding and Escaping</h3>
|
|
|
|
<p>
|
|
|
|
All of these SAM messages are sent on a single line,
|
|
|
|
terminated by the newline character (\n).
|
|
|
|
Prior to SAM 3.2, only 7-bit ASCII was supported.
|
|
|
|
As of SAM 3.2, the encoding must be UTF-8.
|
|
|
|
Any UTF8-encoded keys or values should work.
|
|
|
|
|
|
|
|
</p><p>
|
|
|
|
The formatting shown in this specification
|
|
|
|
below is merely for readability, and while the first two words in
|
|
|
|
each message must stay in their specific order, the ordering of
|
|
|
|
the key=value pairs can change (e.g. "ONE TWO A=B C=D" or
|
|
|
|
"ONE TWO C=D A=B" are both perfectly valid constructions).
|
|
|
|
In addition, the protocol is case-sensitive.
|
|
|
|
In the following, message examples are preceded by "-> " for
|
|
|
|
messages sent by the client to the SAM bridge, and by "<- " for
|
|
|
|
messages sent by the SAM bridge to the client.
|
|
|
|
|
|
|
|
</p><p>
|
|
|
|
The basic command or response line takes one of the following forms:
|
|
|
|
<pre>
|
|
|
|
COMMAND SUBCOMMAND [key=value] [key=value] ...
|
|
|
|
COMMAND # As of SAM 3.2
|
|
|
|
PING[ arbitrary text] # As of SAM 3.2
|
|
|
|
PONG[ arbitrary text] # As of SAM 3.2
|
|
|
|
</pre>
|
|
|
|
COMMAND without a SUBCOMMAND is supported for some new commands in SAM 3.2 only.
|
|
|
|
|
|
|
|
|
|
|
|
</p><p>
|
|
|
|
Key=value pairs must be separated by
|
|
|
|
a single space. (As of SAM 3.2, multiple spaces are allowed)
|
|
|
|
Values may be enclosed in double quotes if they contain spaces,
|
|
|
|
e.g. key="long value text".
|
|
|
|
(Prior to SAM 3.2, this did not work reliably in some implementations)
|
|
|
|
</p><p>
|
|
|
|
Prior to SAM 3.2, there was no escaping mechanism.
|
|
|
|
As of SAM 3.2, double quotes may be escaped with a backslash '\'
|
|
|
|
and a backslash may be represented as two backslashes '\\'.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<h3>Empty values</h3>
|
|
|
|
<p>
|
|
|
|
As of SAM 3.2,
|
|
|
|
empty option values such as KEY, KEY=, or KEY="" may be allowed, implementation dependent.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<h3>Case Sensitivity</h3>
|
|
|
|
<p>
|
|
|
|
The protocol, as specified, is case-sensitive.
|
|
|
|
It is recommended but not required that the server map commands to upper case, for ease in testing via telnet.
|
|
|
|
This would allow, for example, "hello version" to work.
|
|
|
|
This is implementation-dependent.
|
|
|
|
Do not map keys or values to upper case, as this would corrupt I2CP options.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 19:34:18 +00:00
|
|
|
<h3>SAM Connection Handshake</h3>
|
2015-05-12 14:24:36 +00:00
|
|
|
<p>
|
2009-05-06 19:46:57 +00:00
|
|
|
No SAM communication can occur until after the client and bridge have
|
|
|
|
agreed on a protocol version, which is done by the client sending
|
|
|
|
a HELLO and the bridge sending a HELLO REPLY:
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2016-01-03 00:13:11 +00:00
|
|
|
-> HELLO VERSION
|
|
|
|
[MIN=$min] # Optional as of SAM 3.1, required for 3.0 and earlier
|
|
|
|
[MAX=$max] # Optional as of SAM 3.1, required for 3.0 and earlier
|
|
|
|
[USER="xxx"] # As of SAM 3.2, required if authentication is enabled, see below
|
|
|
|
[PASSWORD="yyy"] # As of SAM 3.2, required if authentication is enabled, see below
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
and
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2014-06-28 15:56:00 +00:00
|
|
|
<- HELLO REPLY RESULT=OK VERSION=3.1
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2014-06-28 15:56:00 +00:00
|
|
|
As of version 3.1 (I2P 0.9.14), the MIN and MAX parameters are optional.
|
|
|
|
SAM will always return the highest version possible given the
|
2016-01-03 00:13:11 +00:00
|
|
|
MIN and MAX constraints, or the current server version if no constraints are given.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-11-26 14:31:47 +00:00
|
|
|
If the SAM bridge cannot find a suitable version, it replies with:
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2010-08-16 01:55:25 +00:00
|
|
|
<- HELLO REPLY RESULT=NOVERSION
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2015-11-26 14:31:47 +00:00
|
|
|
If some error occurred, such as a bad request format, it replies with:
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
|
|
|
<- HELLO REPLY RESULT=I2P_ERROR MESSAGE=$message
|
|
|
|
</pre>
|
|
|
|
</p>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
|
2016-02-10 15:01:13 +00:00
|
|
|
<h4 id="ssl">SSL</h4>
|
2016-01-03 00:13:11 +00:00
|
|
|
<p>
|
|
|
|
The server's control socket may optionally offer SSL/TLS support, as configured on the server and client.
|
|
|
|
Implementations may offer other transport layers as well; this is outside the scope of the protocol definition.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
2016-02-10 15:01:13 +00:00
|
|
|
<h4 id="userpw">Authorization</h4>
|
2016-01-03 00:13:11 +00:00
|
|
|
<p>
|
|
|
|
For authorization, client adds USER="xxx" PASSWORD="yyy" to the HELLO parameters.
|
|
|
|
Double quotes for user and password are recommended but not required.
|
|
|
|
A double quote inside a user or password must be escaped with a backslash.
|
|
|
|
On failure the server will reply with an I2P_ERROR and a message.
|
|
|
|
It is recommended that SSL be enabled on any SAM servers where authorization is required.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<h4>Timeouts</h4>
|
|
|
|
<p>
|
|
|
|
Servers may implement timeouts for the HELLO or subsequent commands, implementation dependent.
|
|
|
|
Clients should promptly send the HELLO and the next command after connecting.
|
|
|
|
</p><p>
|
|
|
|
If a timeout occurs before the HELLO is received, the bridge replies with:
|
|
|
|
<pre>
|
|
|
|
<- HELLO REPLY RESULT=I2P_ERROR MESSAGE=$message
|
|
|
|
</pre>
|
|
|
|
and then disconnects.
|
|
|
|
</p><p>
|
|
|
|
If a timeout occurs after the HELLO is received but before the next command, the bridge replies with:
|
|
|
|
<pre>
|
|
|
|
<- SESSION STATUS RESULT=I2P_ERROR MESSAGE=$message
|
|
|
|
</pre>
|
|
|
|
and then disconnects.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<h3>I2CP Ports and Protocol</h3>
|
|
|
|
<p>
|
|
|
|
As of SAM 3.2, the I2CP ports and protocol may be specified by the
|
|
|
|
SAM client sender to be passed through to I2CP, and
|
|
|
|
the SAM bridge will pass the received I2CP port and protocol
|
|
|
|
information to the SAM client.
|
|
|
|
</p><p>
|
|
|
|
For FROM_PORT and TO_PORT, the valid range is 0-65535, and the default is 0.
|
|
|
|
</p><p>
|
|
|
|
For PROTOCOL, which may be specified only for RAW, the valid range is 0-255, and the default is 18.
|
|
|
|
</p><p>
|
|
|
|
For SESSION commands, the specified ports and protocol are the defaults for that session.
|
|
|
|
For individual streams or datagrams, the specified ports and protocol override the session defaults.
|
|
|
|
For received streams or datagrams, the indicated ports and protocol are as received from I2CP.
|
|
|
|
</p><p>
|
|
|
|
See the I2CP specification for more information.
|
|
|
|
</p><p>
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-05-12 19:34:18 +00:00
|
|
|
<h3>SAM Sessions</h3>
|
2015-05-12 14:24:36 +00:00
|
|
|
<p>
|
2009-05-06 19:46:57 +00:00
|
|
|
A SAM session is created by a client opening a socket to the SAM
|
|
|
|
bridge, operating a handshake, and sending a SESSION CREATE message,
|
|
|
|
and the session terminates when the socket is disconnected.
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
Each registered I2P Destination is uniquely associated with a session ID
|
|
|
|
(or nickname).
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2015-11-26 14:31:47 +00:00
|
|
|
Each session is uniquely associated with:
|
2016-01-03 00:13:11 +00:00
|
|
|
</p>
|
2015-05-12 14:24:36 +00:00
|
|
|
<ul><li>
|
|
|
|
the socket from which the client creates the session
|
|
|
|
</li><li>
|
|
|
|
its ID (or nickname)
|
|
|
|
</li></ul>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
<h4>Session Creation Request</h4>
|
|
|
|
<p>
|
2009-05-06 19:46:57 +00:00
|
|
|
The session creation message can only use one of these forms (messages
|
|
|
|
received through other forms are answered with an error message) :
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2010-08-16 01:55:25 +00:00
|
|
|
-> SESSION CREATE
|
2009-05-06 19:46:57 +00:00
|
|
|
STYLE={STREAM,DATAGRAM,RAW}
|
2015-05-12 14:24:36 +00:00
|
|
|
ID=$nickname
|
|
|
|
DESTINATION={$privkey,TRANSIENT}
|
2017-04-01 23:49:52 +00:00
|
|
|
[SIGNATURE_TYPE=value] # SAM 3.1 or higher only, for DESTINATION=TRANSIENT only, default DSA_SHA1
|
2016-01-04 16:51:10 +00:00
|
|
|
[PORT=$port] # Required for DATAGRAM and RAW, invalid for STREAM
|
|
|
|
[HOST=$host] # Optional for DATAGRAM and RAW, invalid for STREAM
|
2016-01-03 00:13:11 +00:00
|
|
|
[FROM_PORT=nnn] # SAM 3.2 or higher only, default 0
|
|
|
|
[TO_PORT=nnn] # SAM 3.2 or higher only, default 0
|
|
|
|
[PROTOCOL=nnn] # SAM 3.2 or higher only, for STYLE=RAW only, default 18
|
|
|
|
[HEADER={true,false}] # SAM 3.2 or higher only, for STYLE=RAW only, default false
|
2016-02-06 19:31:23 +00:00
|
|
|
[option=value]* # I2CP and streaming options
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
DESTINATION specifies what destination should be used for
|
2015-05-12 14:24:36 +00:00
|
|
|
sending and receiving messages/streams.
|
|
|
|
The $privkey is the base 64 of the concatenation of the <a href="{{ site_url('docs/spec/common-structures') }}#type_Destination">Destination</a>
|
|
|
|
followed by the <a href="{{ site_url('docs/spec/common-structures') }}#type_PrivateKey">Private Key</a>
|
|
|
|
followed by the <a href="{{ site_url('docs/spec/common-structures') }}#type_SigningPrivateKey">Signing Private Key</a>,
|
|
|
|
which is 663 or more bytes in binary and 884 or more bytes in base 64,
|
|
|
|
depending on signature type.
|
2018-04-06 15:21:22 +00:00
|
|
|
The binary format is specified in <a href="http://{{ i2pconv('echelon.i2p/javadoc') }}/net/i2p/data/PrivateKeyFile.html">Private Key File</a>.
|
2015-05-12 14:24:36 +00:00
|
|
|
|
|
|
|
</p><p>
|
2014-06-28 15:56:00 +00:00
|
|
|
If the destination is specified as TRANSIENT, the SAM bridge creates a new destination.
|
|
|
|
As of version 3.1 (I2P 0.9.14), if the destination is TRANSIENT, an optional parameter
|
|
|
|
SIGNATURE_TYPE is supported. The SIGNATURE_TYPE value may be any name
|
|
|
|
(e.g. ECDSA_SHA256_P256, case insensitive) or number (e.g. 1)
|
2014-06-30 14:47:25 +00:00
|
|
|
supported by <a href="{{ site_url('docs/spec/common-structures') }}#type_Certificate">Key Certificates</a>.
|
2014-06-28 15:56:00 +00:00
|
|
|
The default is DSA_SHA1.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
|
|
|
$nickname is the choice of the client. No whitespace is allowed.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
Additional options given are passed to the I2P session
|
|
|
|
configuration if not interpreted by the SAM bridge (e.g.
|
2018-03-01 14:44:11 +00:00
|
|
|
outbound.length=0). These options <a href="#options">are documented below</a>.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
The SAM bridge itself should already be configured with what router
|
|
|
|
it should communicate over I2P through (though if need be there may
|
|
|
|
be a way to provide an override, e.g. i2cp.tcp.host=localhost and
|
|
|
|
i2cp.tcp.port=7654).
|
2016-01-03 00:13:11 +00:00
|
|
|
</p>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2016-02-06 19:31:23 +00:00
|
|
|
<h4 id="sessionresponse">Session Creation Response</h4>
|
2016-01-03 00:13:11 +00:00
|
|
|
<p>
|
2009-05-06 19:46:57 +00:00
|
|
|
After receiving the session create message, the SAM bridge will reply
|
|
|
|
with a session status message, as follows:
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2015-11-26 14:31:47 +00:00
|
|
|
If the creation was successful:
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
|
|
|
<- SESSION STATUS RESULT=OK DESTINATION=$privkey
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
</p><p>
|
|
|
|
The $privkey is the base 64 of the concatenation of the <a href="{{ site_url('docs/spec/common-structures') }}#type_Destination">Destination</a>
|
|
|
|
followed by the <a href="{{ site_url('docs/spec/common-structures') }}#type_PrivateKey">Private Key</a>
|
|
|
|
followed by the <a href="{{ site_url('docs/spec/common-structures') }}#type_SigningPrivateKey">Signing Private Key</a>,
|
|
|
|
which is 663 or more bytes in binary and 884 or more bytes in base 64,
|
|
|
|
depending on signature type.
|
2018-04-06 15:21:22 +00:00
|
|
|
The binary format is specified in <a href="http://{{ i2pconv('echelon.i2p/javadoc') }}/net/i2p/data/PrivateKeyFile.html">Private Key File</a>.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2015-11-26 14:31:47 +00:00
|
|
|
If the nickname is already associated with a session:
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2010-08-16 01:55:25 +00:00
|
|
|
<- SESSION STATUS RESULT=DUPLICATED_ID
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2015-11-26 14:31:47 +00:00
|
|
|
If the destination is already in use:
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2010-08-16 01:55:25 +00:00
|
|
|
<- SESSION STATUS RESULT=DUPLICATED_DEST
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2015-11-26 14:31:47 +00:00
|
|
|
If the destination is not a valid private destination key:
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2010-08-16 01:55:25 +00:00
|
|
|
<- SESSION STATUS RESULT=INVALID_KEY
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2015-11-26 14:31:47 +00:00
|
|
|
If some other error has occurred:
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
|
|
|
<- SESSION STATUS RESULT=I2P_ERROR MESSAGE=$message
|
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
If it's not OK, the MESSAGE should contain human-readable information
|
|
|
|
as to why the session could not be created.
|
|
|
|
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
SAM sessions live and die with the socket they are associated with.
|
|
|
|
When the socket is closed, the session dies, and all communications
|
|
|
|
using the session die at the same time. And the other way round, when
|
|
|
|
the session dies for any reason, the SAM bridge closes the socket.
|
2015-05-12 14:24:36 +00:00
|
|
|
</p>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
|
|
|
|
2015-05-12 19:34:18 +00:00
|
|
|
<h3>SAM Virtual Streams</h3>
|
2015-05-12 14:24:36 +00:00
|
|
|
<p>
|
2009-05-06 19:46:57 +00:00
|
|
|
Virtual streams are guaranteed to be sent reliably and in order, with
|
|
|
|
failure and success notification as soon as it is available.
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
Streams are bidirectional communication sockets between two I2P
|
|
|
|
destinations, but their opening has to be requested by one of them.
|
|
|
|
Hereafter, CONNECT commands are used by the SAM client for such a
|
|
|
|
request. FORWARD / ACCEPT commands are used by the SAM client when
|
|
|
|
he wants to listen to requests coming from other I2P destinations.
|
2015-05-12 14:24:36 +00:00
|
|
|
</p>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
|
|
|
|
2015-05-12 19:34:18 +00:00
|
|
|
<h3>SAM Virtual Streams : CONNECT</h3>
|
2015-05-12 14:24:36 +00:00
|
|
|
<p>
|
2015-11-26 14:31:47 +00:00
|
|
|
A client asks for a connection by:
|
2016-01-03 00:13:11 +00:00
|
|
|
</p>
|
2015-05-12 14:24:36 +00:00
|
|
|
<ul><li>
|
|
|
|
opening a new socket with the SAM bridge
|
|
|
|
</li><li>
|
|
|
|
passing the same HELLO handshake as above
|
|
|
|
</li><li>
|
2016-01-03 00:13:11 +00:00
|
|
|
sending the STREAM CONNECT command
|
2015-05-12 14:24:36 +00:00
|
|
|
</li></ul>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
<h4>Connect Request</h4>
|
|
|
|
<p>
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2010-08-16 01:55:25 +00:00
|
|
|
-> STREAM CONNECT
|
2015-05-12 14:24:36 +00:00
|
|
|
ID=$nickname
|
|
|
|
DESTINATION=$destination
|
2016-01-03 00:13:11 +00:00
|
|
|
[SILENT={true,false}] # default false
|
|
|
|
[FROM_PORT=nnn] # SAM 3.2 or higher only, default 0
|
|
|
|
[TO_PORT=nnn] # SAM 3.2 or higher only, default 0
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
This establishes a new virtual connection from the local session
|
2015-05-12 14:24:36 +00:00
|
|
|
whose ID is $nickname to the specified peer.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
|
|
|
The target is $destination, which is the base 64 of the <a href="{{ site_url('docs/spec/common-structures') }}#type_Destination">Destination</a>,
|
|
|
|
which is 516 or more base 64 characters (387 or more bytes in binary),
|
|
|
|
depending on signature type.
|
2016-01-03 00:13:11 +00:00
|
|
|
</p>
|
2015-05-12 14:24:36 +00:00
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
<h4>Connect Response</h4>
|
|
|
|
<p>
|
2012-12-30 22:23:48 +00:00
|
|
|
If SILENT=true is passed, the SAM bridge won't issue any other message
|
2015-11-26 14:31:47 +00:00
|
|
|
on the socket. If the connection fails, the socket will be closed.
|
2009-05-06 19:46:57 +00:00
|
|
|
If the connection succeeds, all remaining data passing through the
|
|
|
|
current socket is forwarded from and to the connected I2P destination
|
|
|
|
peer.
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2012-12-30 22:23:48 +00:00
|
|
|
If SILENT=false, which is the default value, the SAM bridge sends a
|
2009-05-06 19:46:57 +00:00
|
|
|
last message to its client before forwarding or shutting down the
|
2015-11-26 14:31:47 +00:00
|
|
|
socket:
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2010-08-16 01:55:25 +00:00
|
|
|
<- STREAM STATUS
|
2009-05-06 19:46:57 +00:00
|
|
|
RESULT=$result
|
|
|
|
[MESSAGE=...]
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
The RESULT value may be one of:
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
OK
|
|
|
|
CANT_REACH_PEER
|
|
|
|
I2P_ERROR
|
|
|
|
INVALID_KEY
|
|
|
|
INVALID_ID
|
|
|
|
TIMEOUT
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
If the RESULT is OK, all remaining data passing through the
|
|
|
|
current socket is forwarded from and to the connected I2P destination
|
|
|
|
peer. If the connection was not possible (timeout, etc),
|
|
|
|
RESULT will contain the appropriate error value (accompanied by an
|
|
|
|
optional human-readable MESSAGE), and the SAM bridge closes the
|
|
|
|
socket.
|
2015-05-12 14:24:36 +00:00
|
|
|
</p>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 19:34:18 +00:00
|
|
|
<h3>SAM Virtual Streams : ACCEPT</h3>
|
2015-05-12 14:24:36 +00:00
|
|
|
<p>
|
2015-11-26 14:31:47 +00:00
|
|
|
A client waits for an incoming connection request by:
|
2016-01-03 00:13:11 +00:00
|
|
|
</p>
|
2015-05-12 14:24:36 +00:00
|
|
|
<ul><li>
|
|
|
|
opening a new socket with the SAM bridge
|
|
|
|
</li><li>
|
|
|
|
passing the same HELLO handshake as above
|
|
|
|
</li><li>
|
2016-01-03 00:13:11 +00:00
|
|
|
sending the STREAM ACCEPT command
|
2015-05-12 14:24:36 +00:00
|
|
|
</li></ul>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
<h4>Accept Request</h4>
|
|
|
|
<p>
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2010-08-16 01:55:25 +00:00
|
|
|
-> STREAM ACCEPT
|
2015-05-12 14:24:36 +00:00
|
|
|
ID=$nickname
|
2016-01-03 00:13:11 +00:00
|
|
|
[SILENT={true,false}] # default false
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
This makes the session ${nickname} listen for one incoming
|
|
|
|
connection request from the I2P network.
|
2016-01-03 16:37:29 +00:00
|
|
|
ACCEPT is not allowed while there is an active FORWARD on the session.
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2016-01-03 00:13:11 +00:00
|
|
|
As of SAM 3.2,
|
|
|
|
multiple concurrent pending STREAM ACCEPTs are allowed on the same session ID (even with the same port).
|
|
|
|
Prior to 3.2, concurrent accepts would fail with ALREADY_ACCEPTING.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<h4>Accept Response</h4>
|
|
|
|
<p>
|
2015-11-26 14:31:47 +00:00
|
|
|
If SILENT=true is passed, the SAM bridge won't issue any other message
|
|
|
|
on the socket. If the accept fails, the socket will be closed.
|
|
|
|
If the accept succeeds, all remaining data passing through the
|
|
|
|
current socket is forwarded from and to the connected I2P destination
|
|
|
|
peer.
|
|
|
|
For reliability, and to receive the destination for incoming connections,
|
|
|
|
SILENT=false is recommended.
|
|
|
|
|
|
|
|
|
|
|
|
</p><p>
|
|
|
|
If SILENT=false, which is the default value,
|
|
|
|
the SAM bridge answers with:
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2010-08-16 01:55:25 +00:00
|
|
|
<- STREAM STATUS
|
2009-05-06 19:46:57 +00:00
|
|
|
RESULT=$result
|
|
|
|
[MESSAGE=...]
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
The RESULT value may be one of:
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
OK
|
|
|
|
I2P_ERROR
|
|
|
|
INVALID_ID
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
If the result is not OK, the socket is closed immediately by the SAM
|
|
|
|
bridge. If the result is OK, the SAM bridge starts waiting for an
|
|
|
|
incoming connection request from another I2P peer. When a request
|
2015-11-26 14:31:47 +00:00
|
|
|
arrives, the SAM bridge accepts it and:
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
|
|
|
If SILENT=true was passed, the SAM bridge won't issue any other message
|
2015-11-26 14:31:47 +00:00
|
|
|
on the client socket. All remaining data passing through the
|
2009-05-06 19:46:57 +00:00
|
|
|
current socket is forwarded from and to the connected I2P destination
|
|
|
|
peer.
|
2015-05-12 14:24:36 +00:00
|
|
|
|
|
|
|
</p><p>
|
|
|
|
If SILENT=false was passed, which is the default value, the SAM bridge
|
2009-05-06 19:46:57 +00:00
|
|
|
sends the client a ASCII line containing the base64 public destination key
|
2016-01-03 00:13:11 +00:00
|
|
|
of the requesting peer, and additional information for SAM 3.2 only:
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
$destination
|
|
|
|
FROM_PORT=nnn # SAM 3.2 or higher only
|
|
|
|
TO_PORT=nnn # SAM 3.2 or higher only
|
|
|
|
\n
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
After this '\n' terminated line, all remaining data
|
2009-05-06 19:46:57 +00:00
|
|
|
passing through the current socket is forwarded from and to the connected
|
|
|
|
I2P destination peer, until one of the peer closes the socket.
|
2015-05-12 14:24:36 +00:00
|
|
|
</p>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 19:34:18 +00:00
|
|
|
<h3>SAM Virtual Streams : FORWARD</h3>
|
2015-05-12 14:24:36 +00:00
|
|
|
<p>
|
2009-05-06 19:46:57 +00:00
|
|
|
A client can use a regular socket server and wait for connection requests
|
2015-11-26 14:31:47 +00:00
|
|
|
coming from I2P. For that, the client must:
|
2016-01-03 00:13:11 +00:00
|
|
|
</p>
|
2015-05-12 14:24:36 +00:00
|
|
|
<ul><li>
|
|
|
|
open a new socket with the SAM bridge
|
|
|
|
</li><li>
|
|
|
|
pass the same HELLO handshake as above
|
|
|
|
</li><li>
|
2016-01-03 00:13:11 +00:00
|
|
|
send the forward command
|
2015-05-12 19:34:18 +00:00
|
|
|
</ul></li>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
<h4>Forward Request</h4>
|
|
|
|
<p>
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2010-08-16 01:55:25 +00:00
|
|
|
-> STREAM FORWARD
|
2015-05-12 14:24:36 +00:00
|
|
|
ID=$nickname
|
|
|
|
PORT=$port
|
|
|
|
[HOST=$host]
|
2016-01-03 00:13:11 +00:00
|
|
|
[SILENT={true,false}] # default false
|
|
|
|
[SSL={true,false}] # SAM 3.2 or higher only, default false
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
This makes the session ${nickname} listen for incoming
|
|
|
|
connection requests from the I2P network.
|
2016-01-03 16:37:29 +00:00
|
|
|
FORWARD is not allowed while there is a pending ACCEPT on the session.
|
2016-01-03 00:13:11 +00:00
|
|
|
</p>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
<h4>Forward Response</h4>
|
|
|
|
<p>
|
2015-11-26 14:31:47 +00:00
|
|
|
SILENT defaults to false.
|
|
|
|
Whether SILENT is true or false,
|
|
|
|
the SAM bridge always answers with a STREAM STATUS message.
|
|
|
|
Note that this is a different behavior from STREAM ACCEPT and STREAM CONNECT
|
|
|
|
when SILENT=true.
|
|
|
|
The STREAM STATUS message is:
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2010-08-16 01:55:25 +00:00
|
|
|
<- STREAM STATUS
|
2009-05-06 19:46:57 +00:00
|
|
|
RESULT=$result
|
|
|
|
[MESSAGE=...]
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
The RESULT value may be one of:
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
OK
|
|
|
|
I2P_ERROR
|
|
|
|
INVALID_ID
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
|
|
|
$host is the hostname or IP address of the socket server to which
|
2009-05-06 19:46:57 +00:00
|
|
|
SAM will forward connection requests. If not given, SAM takes the IP
|
|
|
|
of the socket that issued the forward command.
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
|
|
|
$port is the port number of the socket server to which SAM will
|
2009-05-06 19:46:57 +00:00
|
|
|
forward connection requests. It is mandatory.
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2010-08-16 01:55:25 +00:00
|
|
|
When a connection request arrives from I2P, the SAM bridge requests a
|
2015-05-12 14:24:36 +00:00
|
|
|
socket connection from $host:$port. If it is accepted after no more
|
2015-11-26 14:31:47 +00:00
|
|
|
than 3 seconds, SAM will accept the connection from I2P, and then:
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
|
|
|
If SILENT=true was passed, all data passing through the obtained
|
2009-05-06 19:46:57 +00:00
|
|
|
current socket is forwarded from and to the connected I2P destination
|
|
|
|
peer.
|
2015-05-12 14:24:36 +00:00
|
|
|
|
|
|
|
</p><p>
|
|
|
|
If SILENT=false was passed, which is the default value, the SAM bridge
|
2009-05-06 19:46:57 +00:00
|
|
|
sends on the obtained socket an ASCII line containing the base64 public
|
2016-01-03 00:13:11 +00:00
|
|
|
destination key of the requesting peer, and additional information for SAM 3.2 only:
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
$destination
|
|
|
|
FROM_PORT=nnn # SAM 3.2 or higher only
|
|
|
|
TO_PORT=nnn # SAM 3.2 or higher only
|
|
|
|
\n
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
After this '\n' terminated line,
|
2009-05-06 19:46:57 +00:00
|
|
|
all remaining data passing through the socket is forwarded from and to
|
|
|
|
the connected I2P destination peer, until one of the sides closes the
|
|
|
|
socket.
|
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
</p><p>
|
|
|
|
As of SAM 3.2, if SSL=true is specified, the forwarding socket is over SSL/TLS.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
The I2P router will stop listening to incoming connection requests as
|
|
|
|
soon as the "forwarding" socket is closed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-07 19:07:27 +00:00
|
|
|
<h3 id="v3dgsend">SAM Datagrams : Sending Repliable or Raw Datagrams</h3>
|
2015-05-12 14:24:36 +00:00
|
|
|
<p>
|
2009-05-06 19:46:57 +00:00
|
|
|
While I2P doesn't inherently contain a FROM address, for ease of use
|
|
|
|
an additional layer is provided as repliable datagrams - unordered
|
2014-07-19 15:57:32 +00:00
|
|
|
and unreliable messages of up to 31744 bytes that include a FROM
|
2009-05-06 19:46:57 +00:00
|
|
|
address (leaving up to 1KB for header material). This FROM address
|
|
|
|
is authenticated internally by SAM (making use of the destination's
|
|
|
|
signing key to verify the source) and includes replay prevention.
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2014-07-19 15:57:32 +00:00
|
|
|
Minimum size is 1. For best delivery reliability, recommended maximum
|
|
|
|
size is approximately 11 KB.
|
2016-01-03 00:13:11 +00:00
|
|
|
Reliability is inversely proportional to message size, perhaps even exponentially.
|
2014-07-19 15:57:32 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2016-02-07 19:07:27 +00:00
|
|
|
After establishing a SAM session with STYLE=DATAGRAM or STYLE=RAW, the client can
|
|
|
|
send repliable or raw datagrams through SAM's UDP port (7655).
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2015-11-26 14:31:47 +00:00
|
|
|
The first line of a datagram sent through this port must be in the
|
2016-01-03 00:13:11 +00:00
|
|
|
following format.
|
|
|
|
This is all on one line (space separated), shown on multiple lines for clarity:
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
<pre>
|
2016-02-10 15:01:13 +00:00
|
|
|
3.0 # As of SAM 3.2, any "3.x" is allowed. Prior to that, "3.0" is required.
|
2016-01-03 00:13:11 +00:00
|
|
|
$nickname
|
|
|
|
$destination
|
|
|
|
[FROM_PORT=nnn] # SAM 3.2 or higher only, default 0
|
|
|
|
[TO_PORT=nnn] # SAM 3.2 or higher only, default 0
|
2016-02-07 19:07:27 +00:00
|
|
|
[PROTOCOL=nnn] # SAM 3.2 or higher only, only for RAW sessions, default 18
|
|
|
|
[SEND_TAGS=nnn] # SAM 3.3 or higher only, number of session tags to send
|
2016-02-07 20:54:16 +00:00
|
|
|
# Overrides crypto.tagsToSend I2CP session option
|
2016-02-07 19:07:27 +00:00
|
|
|
# Default is router-dependent (40 for Java router)
|
|
|
|
[TAG_THRESHOLD=nnn] # SAM 3.3 or higher only, low session tag threshold
|
2016-02-07 20:54:16 +00:00
|
|
|
# Overrides crypto.lowTagThreshold I2CP session option
|
2016-02-07 19:07:27 +00:00
|
|
|
# Default is router-dependent (30 for Java router)
|
|
|
|
[EXPIRES=nnn] # SAM 3.3 or higher only, expiration from now in seconds
|
2016-02-07 20:54:16 +00:00
|
|
|
# Overrides clientMessageTimeout I2CP session option (which is in ms)
|
2016-02-07 19:07:27 +00:00
|
|
|
# Default is router-dependent (60 for Java router)
|
|
|
|
[SEND_LEASESET={true,false}] # SAM 3.3 or higher only, whether to send our leaseset
|
2016-02-07 20:54:16 +00:00
|
|
|
# Overrides shouldBundleReplyInfo I2CP session option
|
2016-02-07 19:07:27 +00:00
|
|
|
# Default is true
|
2016-01-03 00:13:11 +00:00
|
|
|
\n
|
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<ul><li>
|
2016-01-03 00:13:11 +00:00
|
|
|
3.0 is the version of SAM. As of SAM 3.2, any 3.x is allowed.
|
2015-05-12 14:24:36 +00:00
|
|
|
</li><li>
|
2015-05-12 19:34:18 +00:00
|
|
|
$nickname is the id of the DATAGRAM session that will be used
|
2015-05-12 14:24:36 +00:00
|
|
|
</li><li>
|
|
|
|
The target is $destination, which is the base 64 of the <a href="{{ site_url('docs/spec/common-structures') }}#type_Destination">Destination</a>,
|
|
|
|
which is 516 or more base 64 characters (387 or more bytes in binary),
|
|
|
|
depending on signature type.
|
2016-02-07 19:07:27 +00:00
|
|
|
</li><li>
|
|
|
|
All options are per-datagram settings that override the defaults specified in the SESSION CREATE.
|
|
|
|
</li><li>
|
|
|
|
Version 3.3 options SEND_TAGS, TAG_THRESHOLD, EXPIRES, and SEND_LEASESET
|
2016-03-19 21:21:33 +00:00
|
|
|
will be passed to I2CP if supported. See <a href="../protocol/i2cp#msg_SendMessageExpire">the I2CP specification</a> for details.
|
2016-02-07 19:07:27 +00:00
|
|
|
Support by the SAM server is optional, it will ignore these options if unsupported.
|
2015-05-12 14:24:36 +00:00
|
|
|
</li><li>
|
|
|
|
this line is '\n' terminated.
|
|
|
|
</li></ul>
|
|
|
|
|
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
The first line will be discarded by SAM before sending the remaining
|
2015-11-26 14:31:47 +00:00
|
|
|
data of the message to the specified destination.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2016-02-07 19:07:27 +00:00
|
|
|
For an alternate method of sending repliable and raw datagrams, see <a href="#dgsend">DATAGRAM SEND and RAW SEND</a>.
|
2015-05-12 14:24:36 +00:00
|
|
|
</p>
|
|
|
|
|
2015-05-12 19:34:18 +00:00
|
|
|
<h3>SAM Repliable Datagrams : Receiving a Datagram</h3>
|
2015-05-12 14:24:36 +00:00
|
|
|
<p>
|
2009-05-06 19:46:57 +00:00
|
|
|
Received datagrams are written by SAM on the socket from which the
|
2015-11-27 18:25:52 +00:00
|
|
|
datagram session was opened, if a forwarding PORT is not specified in the SESSION CREATE
|
|
|
|
command. This is the v1/v2-compatible way of receiving datagrams.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
When a datagram arrives, the bridge delivers it to the client via the
|
2015-11-26 14:31:47 +00:00
|
|
|
message:
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2010-08-16 01:55:25 +00:00
|
|
|
<- DATAGRAM RECEIVED
|
2015-05-12 14:24:36 +00:00
|
|
|
DESTINATION=$destination
|
2016-01-03 00:13:11 +00:00
|
|
|
SIZE=$numBytes
|
|
|
|
FROM_PORT=nnn # SAM 3.2 or higher only
|
|
|
|
TO_PORT=nnn # SAM 3.2 or higher only
|
|
|
|
\n
|
2015-11-27 18:25:52 +00:00
|
|
|
[$numBytes of data]
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
|
|
|
|
|
|
|
</p><p>
|
|
|
|
The source is $destination, which is the base 64 of the <a href="{{ site_url('docs/spec/common-structures') }}#type_Destination">Destination</a>,
|
|
|
|
which is 516 or more base 64 characters (387 or more bytes in binary),
|
|
|
|
depending on signature type.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
The SAM bridge never exposes to the client the authentication headers
|
|
|
|
or other fields, merely the data that the sender provided. This
|
|
|
|
continues until the session is closed (by the client dropping the
|
|
|
|
connection).
|
|
|
|
|
2015-11-27 18:25:52 +00:00
|
|
|
<h3>SAM Datagrams : Forwarding Raw or Repliable Datagrams</h3>
|
2015-05-12 14:24:36 +00:00
|
|
|
<p>
|
2009-05-06 19:46:57 +00:00
|
|
|
When creating a datagram session, the client can ask SAM to forward
|
|
|
|
incoming messages to a specified ip:port. It does so by issuing the
|
2015-11-26 14:31:47 +00:00
|
|
|
CREATE command with PORT and HOST options:
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2010-08-16 01:55:25 +00:00
|
|
|
-> SESSION CREATE
|
2015-11-27 18:25:52 +00:00
|
|
|
STYLE={DATAGRAM,RAW}
|
2015-05-12 14:24:36 +00:00
|
|
|
ID=$nickname
|
|
|
|
DESTINATION={$privkey,TRANSIENT}
|
|
|
|
PORT=$port
|
|
|
|
[HOST=$host]
|
2016-01-03 00:13:11 +00:00
|
|
|
[FROM_PORT=nnn] # SAM 3.2 or higher only, default 0
|
|
|
|
[TO_PORT=nnn] # SAM 3.2 or higher only, default 0
|
|
|
|
[PROTOCOL=nnn] # SAM 3.2 or higher only, for STYLE=RAW only, default 18
|
2016-02-06 19:31:23 +00:00
|
|
|
[option=value]* # I2CP options
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
|
|
|
|
|
|
|
</p><p>
|
|
|
|
The $privkey is the base 64 of the concatenation of the <a href="{{ site_url('docs/spec/common-structures') }}#type_Destination">Destination</a>
|
|
|
|
followed by the <a href="{{ site_url('docs/spec/common-structures') }}#type_PrivateKey">Private Key</a>
|
|
|
|
followed by the <a href="{{ site_url('docs/spec/common-structures') }}#type_SigningPrivateKey">Signing Private Key</a>,
|
|
|
|
which is 884 or more base 64 characters (663 or more bytes in binary),
|
|
|
|
depending on signature type.
|
2018-04-06 15:21:22 +00:00
|
|
|
The binary format is specified in <a href="http://{{ i2pconv('echelon.i2p/javadoc') }}/net/i2p/data/PrivateKeyFile.html">Private Key File</a>.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
|
|
|
$host is the hostname or IP address of the datagram server to
|
2009-05-06 19:46:57 +00:00
|
|
|
which SAM will forward datagrams. If not given, SAM takes the
|
|
|
|
IP of the socket that issued the forward command.
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
|
|
|
$port is the port number of the datagram server to which SAM
|
2009-05-06 19:46:57 +00:00
|
|
|
will forward datagrams.
|
2015-11-27 18:25:52 +00:00
|
|
|
If $port is not set, datagrams will NOT be forwarded, they will be received on the control socket,
|
|
|
|
in the v1/v2-compatible way.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2015-05-12 18:46:25 +00:00
|
|
|
Additional options given are passed to the I2P session
|
|
|
|
configuration if not interpreted by the SAM bridge (e.g.
|
2018-03-01 14:44:11 +00:00
|
|
|
outbound.length=0). These options <a href="#options">are documented below</a>.
|
2015-05-12 18:46:25 +00:00
|
|
|
|
|
|
|
</p><p>
|
2015-11-27 18:25:52 +00:00
|
|
|
Forwarded repliable datagrams are always prefixed with the destination.
|
|
|
|
When a repliable datagram arrives, the bridge sends to the specified host:port
|
2015-11-26 14:31:47 +00:00
|
|
|
a UDP packet containing the following data:
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2016-01-03 00:13:11 +00:00
|
|
|
$destination
|
|
|
|
FROM_PORT=nnn # SAM 3.2 or higher only
|
|
|
|
TO_PORT=nnn # SAM 3.2 or higher only
|
|
|
|
\n
|
|
|
|
$datagram_payload
|
2015-11-27 18:25:52 +00:00
|
|
|
</pre>
|
|
|
|
|
|
|
|
</p><p>
|
|
|
|
Forwarded raw datagrams are forwarded as-is
|
|
|
|
to the specified host:port without a prefix.
|
|
|
|
The UDP packet contains the following data:
|
|
|
|
|
|
|
|
<pre>
|
2016-01-03 00:13:11 +00:00
|
|
|
$datagram_payload
|
|
|
|
</pre>
|
|
|
|
|
2016-01-04 16:51:10 +00:00
|
|
|
</p><p>
|
2016-01-03 00:13:11 +00:00
|
|
|
As of SAM 3.2, when HEADER=true is specified in SESSION CREATE,
|
|
|
|
the forwarded raw datagram will be prepended with a header line as follows:
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
FROM_PORT=nnn
|
|
|
|
TO_PORT=nnn
|
|
|
|
PROTOCOL=nnn
|
|
|
|
\n
|
|
|
|
$datagram_payload
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
|
|
|
The $destination is the base 64 of the <a href="{{ site_url('docs/spec/common-structures') }}#type_Destination">Destination</a>,
|
|
|
|
which is 516 or more base 64 characters (387 or more bytes in binary),
|
|
|
|
depending on signature type.
|
|
|
|
</p>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
|
|
|
|
2016-02-07 19:07:27 +00:00
|
|
|
<h3>SAM Anonymous (Raw) Datagrams</h3>
|
2015-05-12 14:24:36 +00:00
|
|
|
<p>
|
2009-05-06 19:46:57 +00:00
|
|
|
Squeezing the most out of I2P's bandwidth, SAM allows clients to send
|
|
|
|
and receive anonymous datagrams, leaving authentication and reply
|
|
|
|
information up to the client themselves. These datagrams are
|
2014-07-19 15:57:32 +00:00
|
|
|
unreliable and unordered, and may be up to 32768 bytes.
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2014-07-19 15:57:32 +00:00
|
|
|
Minimum size is 1. For best delivery reliability, recommended maximum
|
|
|
|
size is approximately 11 KB.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
After establishing a SAM session with STYLE=RAW, the client can
|
2010-03-21 19:41:10 +00:00
|
|
|
send anonymous datagrams through the SAM bridge exactly the same way
|
2016-02-07 19:07:27 +00:00
|
|
|
as <a href="v3dgsend">sending repliable datagrams</a>.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
Both ways of receiving datagrams are also available for anonymous
|
|
|
|
datagrams.
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2015-11-27 18:25:52 +00:00
|
|
|
Received datagrams are written by SAM on the socket from which the
|
|
|
|
datagram session was opened, if a forwarding PORT is not specified in the SESSION CREATE
|
|
|
|
command. This is the v1/v2-compatible way of receiving datagrams.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2010-08-16 01:55:25 +00:00
|
|
|
<- RAW RECEIVED
|
2016-01-03 00:13:11 +00:00
|
|
|
SIZE=$numBytes
|
|
|
|
FROM_PORT=nnn # SAM 3.2 or higher only
|
|
|
|
TO_PORT=nnn # SAM 3.2 or higher only
|
|
|
|
PROTOCOL=nnn # SAM 3.2 or higher only
|
|
|
|
\n
|
2015-11-27 18:25:52 +00:00
|
|
|
[$numBytes of data]
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
When anonymous datagrams are to be forwarded to some host:port,
|
|
|
|
the bridge sends to the specified host:port a message containing
|
2015-11-26 14:31:47 +00:00
|
|
|
the following data:
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2016-01-03 00:13:11 +00:00
|
|
|
$datagram_payload
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
As of SAM 3.2, when HEADER=true is specified in SESSION CREATE,
|
|
|
|
the forwarded raw datagram will be prepended with a header line as follows:
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
FROM_PORT=nnn
|
|
|
|
TO_PORT=nnn
|
|
|
|
PROTOCOL=nnn
|
|
|
|
\n
|
|
|
|
$datagram_payload
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
|
|
|
For an alternate method of sending anonymous datagrams, see <a href="#dgsend">RAW SEND</a>.
|
|
|
|
</p>
|
2014-07-19 15:57:32 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<h3 id="dgsend">DATAGRAM SEND, RAW SEND (V1/V2 Compatible Datagram Handling)</h3>
|
|
|
|
<p>
|
2014-07-19 15:57:32 +00:00
|
|
|
In SAM V3, the preferred way to send datagrams is via the datagram socket
|
|
|
|
at port 7655 as documented above. However, repliable datagrams may be sent
|
|
|
|
directly via the SAM bridge socket using the DATAGRAM SEND command,
|
2014-07-20 12:19:57 +00:00
|
|
|
as documented in <a href="sam">SAM V1</a> and <a href="samv2">SAM V2</a>.
|
2014-07-19 15:57:32 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2014-07-19 15:57:32 +00:00
|
|
|
As of release 0.9.14 (version 3.1), anonymous datagrams may be sent
|
|
|
|
directly via the SAM bridge socket using the RAW SEND command,
|
2014-07-20 14:00:13 +00:00
|
|
|
as documented in <a href="sam">SAM V1</a> and <a href="samv2">SAM V2</a>.
|
2014-07-19 15:57:32 +00:00
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
</p><p>
|
|
|
|
As of release 0.9.24 (version 3.2), DATAGRAM SEND and RAW SEND may include
|
|
|
|
the parameters FROM_PORT=nnnn and/or TO_PORT=nnnn to override the default ports.
|
|
|
|
As of release 0.9.24 (version 3.2), RAW SEND may include
|
|
|
|
the parameter PROTOCOL=nnn to override the default protocol.
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2014-07-19 15:57:32 +00:00
|
|
|
These commands do <i>not</i> support the ID parameter. The datagrams are
|
|
|
|
sent to the most recently created DATAGRAM- or RAW-style session,
|
|
|
|
as appropriate. Support for the ID parameter may be added in a future release.
|
|
|
|
|
|
|
|
|
2016-02-06 19:31:23 +00:00
|
|
|
<h3 id="master">MASTER Sessions (V3.3 and higher)</h3>
|
|
|
|
|
|
|
|
<p><i>
|
2016-04-04 12:05:57 +00:00
|
|
|
Version 3.3 was introduced in I2P release 0.9.25.
|
2016-02-06 19:31:23 +00:00
|
|
|
</i></p>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
SAM v3.3 adds support for running streaming, datagrams, and raw subsessions on the same
|
|
|
|
master session, and for running multiple subsessions of the same style.
|
|
|
|
All subsession traffic uses a single destination, or set of tunnels.
|
|
|
|
Routing of traffic from I2P is based on the port and protocol options for the subsessions.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
To create multiplexed subsessions, you must create a master session
|
|
|
|
and then add subsessions to the master session.
|
|
|
|
Each subsession must have a unique id and a unique listen protocol and port.
|
|
|
|
Subsessions may also be removed from the master session.
|
2016-02-06 20:05:06 +00:00
|
|
|
|
|
|
|
</p><p>
|
|
|
|
With a MASTER session and a combination of subsessions, a SAM client
|
|
|
|
may support multiple applications, or a single sophisticated application
|
2018-03-01 15:00:59 +00:00
|
|
|
using a variety of protocols, on a single set of tunnels.
|
2016-02-06 20:05:06 +00:00
|
|
|
For example, a bittorrent client could set up a streaming subsession
|
|
|
|
for peer-to-peer connections, together with datagram and raw subsessions
|
|
|
|
for DHT communication.
|
2016-02-06 19:31:23 +00:00
|
|
|
</p>
|
|
|
|
|
|
|
|
<h4>Creating a MASTER Session</h4>
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
-> SESSION CREATE
|
|
|
|
STYLE=MASTER
|
|
|
|
ID=$nickname
|
|
|
|
DESTINATION={$privkey,TRANSIENT}
|
|
|
|
[option=value]* # I2CP and streaming options
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
The SAM bridge will respond with success or failure as in <a href="#sessionresponse">the response to a standard SESSION CREATE</a>.
|
|
|
|
</p><p>
|
|
|
|
Do not set the PORT, HOST, FROM_PORT, TO_PORT, PROTOCOL, LISTEN_PORT, LISTEN_PROTOCOL, or HEADER options on a master session.
|
|
|
|
You may not send any data on a MASTER session ID or on the control socket. All commands such as
|
|
|
|
STREAM CONNECT, DATAGRAM SEND, etc. must use the subsession ID on a separate socket.
|
|
|
|
</p><p>
|
|
|
|
The MASTER session connects to the router and builds tunnels. When the SAM bridge responds,
|
|
|
|
tunnels have been built and the session is ready for subsessions to be added.
|
|
|
|
All I2CP options pertaining to tunnel parameters such as length, quantity, and nickname must
|
|
|
|
be provided in the master's SESSION CREATE.
|
|
|
|
</p><p>
|
|
|
|
All utility commands are supported on a master session.
|
|
|
|
</p><p>
|
|
|
|
When the master session is closed, all subsessions get closed also.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<h4>Creating a Subsession</h4>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
Using the same control socket on which the MASTER session was created:
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
-> SESSION ADD
|
|
|
|
STYLE={STREAM,DATAGRAM,RAW}
|
|
|
|
ID=$nickname # must be unique
|
|
|
|
[PORT=$port] # Required for DATAGRAM and RAW, invalid for STREAM
|
|
|
|
[HOST=$host] # Optional for DATAGRAM and RAW, invalid for STREAM
|
|
|
|
[FROM_PORT=nnn] # For outbound traffic, default 0
|
|
|
|
[TO_PORT=nnn] # For outbound traffic, default 0
|
|
|
|
[PROTOCOL=nnn] # For outbound traffic for STYLE=RAW only, default 18
|
|
|
|
[LISTEN_PORT=nnn] # For inbound traffic, default is the FROM_PORT value.
|
|
|
|
# For STYLE=STREAM, only the FROM_PORT value or 0 is allowed.
|
|
|
|
[LISTEN_PROTOCOL=nnn] # For inbound traffic for STYLE=RAW only.
|
|
|
|
# Default is the PROTOCOL value; 6 (streaming) is disallowed
|
|
|
|
[HEADER={true,false}] # For STYLE=RAW only, default false
|
|
|
|
[option=value]* # I2CP and streaming options
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
The SAM bridge will respond with success or failure as in <a href="#sessionresponse">the response to a standard SESSION CREATE</a>.
|
|
|
|
As the tunnels were already built in the master SESSION CREATE, the SAM bridge should respond immediately.
|
|
|
|
</p><p>
|
|
|
|
Do not set the DESTINATION option on a SESSION ADD.
|
|
|
|
The subsession will use the destination specified in the master session.
|
|
|
|
All subsessions must be added on the control socket, i.e. the same connection that you created the master session on.
|
|
|
|
</p><p>
|
|
|
|
Multiple subsessions must have options sufficiently unique
|
|
|
|
that incoming data can be routed correctly.
|
|
|
|
In particular, multiple sessions of the same style must have
|
|
|
|
different LISTEN_PORT options (and/or LISTEN_PROTOCOL, for RAW only).
|
|
|
|
A SESSION ADD with listen port and protocol that duplicates an existing subsession will result in an error.
|
|
|
|
</p><p>
|
|
|
|
The LISTEN_PORT is the local I2P port, i.e. the receive (TO) port for
|
|
|
|
incoming data.
|
|
|
|
If the LISTEN_PORT is not specified, the FROM_PORT value will be used.
|
|
|
|
If the LISTEN_PORT and FROM_PORT are not specified, incoming routing will be based on
|
|
|
|
STYLE and PROTOCOL alone.
|
|
|
|
For LISTEN_PORT and LISTEN_PROTOCOL, 0 means any value, that is, a wildcard.
|
|
|
|
If both LISTEN_PORT and LISTEN_PROTOCOL are 0,
|
|
|
|
this subsession will be the default for incoming traffic that does not get routed to another subsession.
|
|
|
|
Incoming streaming traffic (protocol 6) will never be routed to a RAW subsession, even if its LISTEN_PROTCOL is 0.
|
|
|
|
A RAW subsession may not set a LISTEN_PROTOCOL of 6.
|
|
|
|
If there is no default or subsession that matching the protocol and port of incoming traffic, that data will be dropped.
|
|
|
|
</p><p>
|
|
|
|
Use the subsession ID, not the master session ID, for sending and receiving data.
|
|
|
|
All commands such as STREAM CONNECT, DATAGRAM SEND, etc.
|
|
|
|
must use the subsession ID.
|
|
|
|
|
|
|
|
</p><p>
|
|
|
|
All utility commands are supported on a master session or subsession.
|
|
|
|
v1/v2 datagram/raw sending/receiving are not supported on a master session or on subsessions.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<h4>Stopping a Subsession</h4>
|
|
|
|
<p>
|
|
|
|
Using the same control socket on which the MASTER session was created:
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
-> SESSION REMOVE
|
|
|
|
ID=$nickname
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
This removes a subsession from the master session.
|
|
|
|
Do not set any other options on a SESSION REMOVE.
|
|
|
|
Subsessions must be removed on the control socket, i.e. the same connection that you created the master session on.
|
|
|
|
After a subsession is removed, it is closed and may not be used to send or receive data.
|
|
|
|
</p><p>
|
|
|
|
The SAM bridge will respond with success or failure as in <a href="#sessionresponse">the response to a standard SESSION CREATE</a>.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-07-19 15:57:32 +00:00
|
|
|
|
2015-05-13 12:59:14 +00:00
|
|
|
<h3>SAM Utility Commands</h3>
|
2016-01-03 00:13:11 +00:00
|
|
|
|
2016-09-23 19:36:58 +00:00
|
|
|
<p>
|
|
|
|
Some utility commands require a pre-existing session and some do not.
|
|
|
|
See details below.
|
|
|
|
</p>
|
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
<h4>Host Name Lookup</h4>
|
2015-05-12 14:24:36 +00:00
|
|
|
<p>
|
2009-05-06 19:46:57 +00:00
|
|
|
The following message can be used by the client to query the SAM
|
|
|
|
bridge for name resolution:
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
NAMING LOOKUP
|
|
|
|
NAME=$name
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 19:34:18 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
which is answered by
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
NAMING REPLY
|
|
|
|
RESULT=$result
|
|
|
|
NAME=$name
|
2015-05-12 14:24:36 +00:00
|
|
|
[VALUE=$destination]
|
2009-05-06 19:46:57 +00:00
|
|
|
[MESSAGE=$message]
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
The RESULT value may be one of:
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
OK
|
|
|
|
INVALID_KEY
|
|
|
|
KEY_NOT_FOUND
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
|
|
|
If NAME=ME, then the reply will contain the destination used by the
|
2009-05-06 19:46:57 +00:00
|
|
|
current session (useful if you're using a TRANSIENT one). If $result
|
|
|
|
is not OK, MESSAGE may convey a descriptive message, such as "bad
|
|
|
|
format", etc.
|
2016-09-23 19:36:58 +00:00
|
|
|
INVALID_KEY implies that something is wrong with $name in the request,
|
|
|
|
possibly invalid characters.
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
|
|
|
The $destination is the base 64 of the <a href="{{ site_url('docs/spec/common-structures') }}#type_Destination">Destination</a>,
|
|
|
|
which is 516 or more base 64 characters (387 or more bytes in binary),
|
|
|
|
depending on signature type.
|
|
|
|
|
2016-09-23 19:36:58 +00:00
|
|
|
</p><p>
|
|
|
|
NAMING LOOKUP does not require that a session has been created first.
|
|
|
|
However, in some implementations, a .b32.i2p lookup which is uncached and requires
|
|
|
|
a network query may fail, as no client tunnels are available for the lookup.
|
|
|
|
</p>
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
<h4>Destination Key Generation</h4>
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
Public and private base64 keys can be generated using the following
|
|
|
|
message:
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2017-04-01 23:49:52 +00:00
|
|
|
-> DEST GENERATE
|
|
|
|
[SIGNATURE_TYPE=value] # SAM 3.1 or higher only, default DSA_SHA1
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2009-05-06 19:46:57 +00:00
|
|
|
which is answered by
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
DEST REPLY
|
2015-05-12 14:24:36 +00:00
|
|
|
PUB=$destination
|
2009-05-06 19:46:57 +00:00
|
|
|
PRIV=$privkey
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2017-04-01 23:49:52 +00:00
|
|
|
As of version 3.1 (I2P 0.9.14), an optional parameter SIGNATURE_TYPE is supported.
|
2014-06-28 15:56:00 +00:00
|
|
|
The SIGNATURE_TYPE value may be any name (e.g. ECDSA_SHA256_P256, case insensitive) or number (e.g. 1)
|
2014-06-30 14:47:25 +00:00
|
|
|
that is supported by <a href="{{ site_url('docs/spec/common-structures') }}#type_Certificate">Key Certificates</a>.
|
2014-06-28 15:56:00 +00:00
|
|
|
The default is DSA_SHA1.
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
|
|
|
The $destination is the base 64 of the <a href="{{ site_url('docs/spec/common-structures') }}#type_Destination">Destination</a>,
|
|
|
|
which is 516 or more base 64 characters (387 or more bytes in binary),
|
|
|
|
depending on signature type.
|
|
|
|
|
|
|
|
</p><p>
|
|
|
|
The $privkey is the base 64 of the concatenation of the <a href="{{ site_url('docs/spec/common-structures') }}#type_Destination">Destination</a>
|
|
|
|
followed by the <a href="{{ site_url('docs/spec/common-structures') }}#type_PrivateKey">Private Key</a>
|
|
|
|
followed by the <a href="{{ site_url('docs/spec/common-structures') }}#type_SigningPrivateKey">Signing Private Key</a>,
|
|
|
|
which is 884 or more base 64 characters (663 or more bytes in binary),
|
|
|
|
depending on signature type.
|
2018-04-06 15:21:22 +00:00
|
|
|
The binary format is specified in <a href="http://{{ i2pconv('echelon.i2p/javadoc') }}/net/i2p/data/PrivateKeyFile.html">Private Key File</a>.
|
2015-05-12 14:24:36 +00:00
|
|
|
|
2016-09-23 19:36:58 +00:00
|
|
|
</p><p>
|
|
|
|
DEST GENERATE does not require that a session has been created first.
|
|
|
|
</p>
|
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
|
|
|
|
<h4>PING/PONG (SAM 3.2 or higher)</h4>
|
|
|
|
<p>
|
|
|
|
Either the client or server may send:
|
|
|
|
<pre>
|
|
|
|
PING[ arbitrary text]
|
|
|
|
</pre>
|
|
|
|
on the control port,
|
|
|
|
with the response:
|
|
|
|
<pre>
|
|
|
|
PONG[ arbitrary text from the ping]
|
|
|
|
</pre>
|
|
|
|
to be used for control socket keepalive.
|
|
|
|
Either side may close the session and socket if no response is received in a reasonable time, implementation dependent.
|
|
|
|
</p><p>
|
|
|
|
If a timeout occurs waiting for a PONG from the client, the bridge may send:
|
|
|
|
<pre>
|
|
|
|
<- SESSION STATUS RESULT=I2P_ERROR MESSAGE=$message
|
|
|
|
</pre>
|
|
|
|
and then disconnect.
|
|
|
|
</p><p>
|
|
|
|
If a timeout occurs waiting for a PONG from the bridge, the client may simply disconnect.
|
2016-09-23 19:36:58 +00:00
|
|
|
|
|
|
|
</p><p>
|
|
|
|
PING/PONG do not require that a session has been created first.
|
2016-01-03 00:13:11 +00:00
|
|
|
</p>
|
|
|
|
|
|
|
|
|
2016-02-10 15:01:13 +00:00
|
|
|
<h4 id="quit">QUIT/STOP/EXIT (SAM 3.2 or higher, optional features)</h4>
|
2016-01-03 00:13:11 +00:00
|
|
|
<p>
|
|
|
|
Commands QUIT, STOP and EXIT will close the session and socket.
|
|
|
|
Implementation is optional, for ease in testing via telnet.
|
|
|
|
Whether there is any response before the socket is closed
|
|
|
|
(for example, a SESSION STATUS message) is
|
|
|
|
implementation-specific and outside the scope of this specification.
|
2016-09-23 19:36:58 +00:00
|
|
|
|
|
|
|
</p><p>
|
|
|
|
QUIT/STOP/EXIT do not require that a session has been created first.
|
2016-01-03 00:13:11 +00:00
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<h4>HELP (optional feature)</h4>
|
|
|
|
<p>
|
|
|
|
Servers may implement a HELP command.
|
|
|
|
Implementation is optional, for ease in testing via telnet.
|
|
|
|
Output format and detection of the end of the output is
|
|
|
|
implementation-specific and outside the scope of this specification.
|
2016-09-23 19:36:58 +00:00
|
|
|
|
|
|
|
</p><p>
|
|
|
|
HELP does not require that a session has been created first.
|
2016-01-03 00:13:11 +00:00
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-10 15:01:13 +00:00
|
|
|
<h4 id="auth">Authorization Configuration (SAM 3.2 or higher, optional feature)</h4>
|
2016-01-03 00:13:11 +00:00
|
|
|
<p>
|
|
|
|
Authorization configuration using the AUTH command.
|
|
|
|
A SAM server may implement these commands to facilite persistent storage of credentials.
|
|
|
|
Configuration of authentication other than with these commands is
|
|
|
|
implementation-specific and outside the scope of this specification.
|
|
|
|
</p>
|
|
|
|
<ul>
|
|
|
|
<li>AUTH ENABLE enables authorization on subsequent connections
|
|
|
|
<li>AUTH DISABLE disables authorization on subsequent connections
|
|
|
|
<li>AUTH ADD USER="foo" PASSWORD="bar" adds a user/password
|
|
|
|
<li>AUTH REMOVE USER="foo" removes this user
|
|
|
|
</ul>
|
|
|
|
<p>
|
|
|
|
Double quotes for user and password are recommended but not required.
|
|
|
|
A double quote inside a user or password must be escaped with a backslash.
|
|
|
|
On failure the server will reply with an I2P_ERROR and a message.
|
2016-09-27 14:32:12 +00:00
|
|
|
|
|
|
|
</p><p>
|
|
|
|
AUTH does not require that a session has been created first.
|
2016-01-03 00:13:11 +00:00
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-05-12 19:34:18 +00:00
|
|
|
<h3>RESULT Values</h3>
|
2015-05-12 14:24:36 +00:00
|
|
|
<p>
|
2009-05-06 19:46:57 +00:00
|
|
|
These are the values that can be carried by the RESULT field, with
|
|
|
|
their meaning:
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<pre>
|
2010-08-17 09:54:34 +00:00
|
|
|
OK Operation completed successfully
|
2009-05-06 19:46:57 +00:00
|
|
|
CANT_REACH_PEER The peer exists, but cannot be reached
|
|
|
|
DUPLICATED_DEST The specified Destination is already in use
|
|
|
|
I2P_ERROR A generic I2P error (e.g. I2CP disconnection, etc.)
|
|
|
|
INVALID_KEY The specified key is not valid (bad format, etc.)
|
|
|
|
KEY_NOT_FOUND The naming system can't resolve the given name
|
|
|
|
PEER_NOT_FOUND The peer cannot be found on the network
|
|
|
|
TIMEOUT Timeout while waiting for an event (e.g. peer answer)
|
2015-05-12 14:24:36 +00:00
|
|
|
</pre>
|
2009-05-06 19:46:57 +00:00
|
|
|
|
2010-08-16 01:55:25 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<h3 id="options">Tunnel, I2CP, and Streaming Options</h3>
|
|
|
|
<p>
|
2010-08-16 01:55:25 +00:00
|
|
|
These options may be passed in as name=value pairs at the end of a
|
2009-05-06 19:46:57 +00:00
|
|
|
SAM SESSION CREATE line.
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p><p>
|
2013-02-06 01:55:33 +00:00
|
|
|
All sessions may include <a href="{{ site_url('docs/protocol/i2cp') }}#options">I2CP options such as tunnel lengths</a>.
|
|
|
|
STREAM sessions may include <a href="{{ site_url('docs/api/streaming') }}#options">Streaming lib options</a>.
|
2010-08-16 01:55:25 +00:00
|
|
|
See those references for option names and defaults.
|
|
|
|
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<h3>BASE 64 Notes</h3>
|
2010-08-16 01:55:25 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<p>
|
2010-08-16 01:55:25 +00:00
|
|
|
Base 64 encoding must use the I2P standard Base 64 alphabet "A-Z, a-z, 0-9, -, ~".
|
2015-05-12 14:24:36 +00:00
|
|
|
</p>
|
2010-08-16 01:55:25 +00:00
|
|
|
|
2015-05-12 19:34:18 +00:00
|
|
|
<h3>Client Library Implementations</h3>
|
2015-05-12 14:24:36 +00:00
|
|
|
<p>
|
2010-08-16 01:55:25 +00:00
|
|
|
Client libraries are available for C, C++, C#, Perl, and Python.
|
2013-02-06 01:55:33 +00:00
|
|
|
These are in the apps/sam/ directory in the <a href="{{ get_url('downloads_list') }}">I2P Source Package</a>.
|
2010-08-16 01:55:25 +00:00
|
|
|
Some may be older and have not been updated for SAMv3 support.
|
2015-05-12 14:24:36 +00:00
|
|
|
</p>
|
2010-08-16 01:55:25 +00:00
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
<h3>Default SAM Setup</h3>
|
|
|
|
<p>
|
2016-01-03 00:13:11 +00:00
|
|
|
The default SAM port is 7656. SAM is not enabled by default in the Java I2P Router;
|
2010-08-16 01:55:25 +00:00
|
|
|
it must be started manually, or configured to start automatically,
|
|
|
|
on the configure clients page in the router console, or in the clients.config file.
|
2016-01-03 00:13:11 +00:00
|
|
|
The default SAM UDP port is 7655, listening on 127.0.0.1.
|
2010-08-16 01:55:25 +00:00
|
|
|
These may be changed by adding the arguments sam.udp.port=nnnnn and/or
|
|
|
|
sam.udp.host=w.x.y.z to the invocation.
|
|
|
|
|
2016-01-03 00:13:11 +00:00
|
|
|
</p><p>
|
|
|
|
Configuration in other routers is implementation-specific.
|
|
|
|
|
2015-05-12 14:24:36 +00:00
|
|
|
</p>
|
2009-05-06 19:46:57 +00:00
|
|
|
{% endblock %}
|