Skip to main content

Module sam

Module sam 

Source
Expand description

A minimal SAMv3 client for a router the user already runs. It speaks five commands and nothing else: transient STREAM sessions that never publish a LeaseSet or build a zero-hop tunnel, outbound stream connects, name lookups and a liveness probe. No line it sends can make the router accept a connection or carry someone else’s traffic.

Structs§

ControlSocket
A session’s control socket. Dropping it ends the session: the router tears a session down within half a second of its control socket closing.
RouterTest
What the router test in Settings reports: a HELLO, no session.
SamAuth
SamVersion

Enums§

ControlEvent
What the router said on a session’s control socket.
HelloError
Liveness
StreamFail

Constants§

SAM_HOST
SAM is cleartext, so it never leaves the loopback interface.

Functions§

b32_of
xxxx.b32.i2p for a destination in I2P’s base64 (- and ~ stand for + and /).
connect
Open a stream from session nick to dest (a .b32.i2p address or a base64 destination) on to_port. The returned socket IS the stream.
create_session
Create a transient STREAM session named nick on its own control socket.
hello
Open a SAM socket and agree on 3.2 or newer.
hello_text
A short reason for a failed HELLO, for logs and session errors.
liveness
Is session nick alive? A connect to a destination that can’t exist answers at once, without any network traffic: INVALID_KEY for a live session, INVALID_ID for a gone one.
lookup
Resolve a name (or a b32 a router wants as base64) through the router’s address book.
new_nick
A fresh session nickname: 128 random bits, nothing that names the app or the account.
test_router