Documentation ¶
Index ¶
- Constants
- Variables
- func NewID() int32
- func NewReadHexLogger(prefix string, r io.Reader) io.Reader
- func NewReadLogger(prefix string, r io.Reader) io.Reader
- func NewWriteLogger(prefix string, w io.Writer) io.Writer
- func SetAddr(s ...string) func(*Client) error
- func SetAddrMixed(s string, i int) func(*Client) error
- func SetCloseIdle(b bool) func(*Client) error
- func SetCloseIdleTime(u uint) func(*Client) error
- func SetCompression(b bool) func(*Client) error
- func SetDebug(b bool) func(*Client) error
- func SetEncrypt(b bool) func(*Client) error
- func SetFromPort(s string) func(*Client) error
- func SetFromPortInt(i int) func(*Client) error
- func SetHost(s string) func(*Client) error
- func SetInBackups(u uint) func(*Client) error
- func SetInLength(u uint) func(*Client) error
- func SetInQuantity(u uint) func(*Client) error
- func SetInVariance(i int) func(*Client) error
- func SetLeaseSetEncType(b string) func(*Client) error
- func SetLocalDestination(s string) func(*Client) error
- func SetOutBackups(u uint) func(*Client) error
- func SetOutLength(u uint) func(*Client) error
- func SetOutQuantity(u uint) func(*Client) error
- func SetOutVariance(i int) func(*Client) error
- func SetPass(s string) func(*Client) error
- func SetPort(s string) func(*Client) error
- func SetPortInt(i int) func(*Client) error
- func SetReduceIdle(b bool) func(*Client) error
- func SetReduceIdleQuantity(u uint) func(*Client) error
- func SetReduceIdleTime(u uint) func(*Client) error
- func SetSAMMaxVersion(i int) func(*Client) error
- func SetSAMMinVersion(i int) func(*Client) error
- func SetSignatureType(s string) func(*Client) error
- func SetToPort(s string) func(*Client) error
- func SetToPortInt(i int) func(*Client) error
- func SetUnpublished(b bool) func(*Client) error
- func SetUser(s string) func(*Client) error
- func WrapRWC(c io.ReadWriteCloser) io.ReadWriteCloser
- type Client
- func (c *Client) Accept() (net.Conn, error)
- func (c *Client) AcceptI2P() (net.Conn, error)
- func (p *Client) Addr() net.Addr
- func (c *Client) Base32() string
- func (c *Client) Base64() string
- func (c *Client) Close() error
- func (c *Client) CreateDatagramSession(dest string) (string, error)
- func (c *Client) CreateRawSession(dest string) (string, error)
- func (c *Client) CreateSession(style, dest string) (string, error)
- func (c *Client) CreateStreamSession(dest string) (string, error)
- func (c *Client) Destination() string
- func (c *Client) Dial(network, addr string) (net.Conn, error)
- func (c *Client) DialContext(ctx context.Context, network, addr string) (net.Conn, error)
- func (c *Client) DialContextFree(network, addr string) (net.Conn, error)
- func (c *Client) DialDatagramContextFree(addr string) (*DatagramConn, error)
- func (c *Client) DialStreamingContextFree(addr string) (net.Conn, error)
- func (p *Client) ID() string
- func (c *Client) Listen() (net.Listener, error)
- func (c *Client) ListenI2P(dest string) (net.Listener, error)
- func (p *Client) LocalAddr() net.Addr
- func (c *Client) Lookup(name string) (string, error)
- func (c *Client) NewClient(id int32) (*Client, error)
- func (c *Client) NewDestination(kind ...string) (string, string, error)
- func (c *Client) NewID() int32
- func (c *Client) Print() string
- func (p *Client) PrivateAddr() i2pkeys.I2PKeys
- func (c *Client) RemoveAuthUser(user string) error
- func (c *Client) Resolve(ctx context.Context, name string) (context.Context, net.IP, error)
- func (c *Client) SetupAuth(user, password string) error
- func (c *Client) StreamAccept() (*Reply, error)
- func (c *Client) StreamConnect(dest string) error
- func (c *Client) TeardownAuth() error
- type Conn
- type DatagramConn
- func (d *DatagramConn) Close() error
- func (d *DatagramConn) LocalAddr() net.Addr
- func (d *DatagramConn) Read(b []byte) (n int, err error)
- func (d *DatagramConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)
- func (d *DatagramConn) RemoteAddr() net.Addr
- func (d *DatagramConn) SetDeadline(t time.Time) error
- func (d *DatagramConn) SetReadDeadline(t time.Time) error
- func (d *DatagramConn) SetWriteDeadline(t time.Time) error
- func (d *DatagramConn) Write(b []byte) (n int, err error)
- func (d *DatagramConn) WriteTo(p []byte, addr net.Addr) (n int, err error)
- type Option
- type RWC
- type Reply
- type ReplyError
Constants ¶
const ( ResultOk = "OK" //Operation completed successfully ResultCantReachPeer = "CANT_REACH_PEER" //The peer exists, but cannot be reached ResultDuplicatedID = "DUPLICATED_ID" //If the nickname is already associated with a session : ResultDuplicatedDest = "DUPLICATED_DEST" //The specified Destination is already in use ResultI2PError = "I2P_ERROR" //A generic I2P error (e.g. I2CP disconnection, etc.) ResultInvalidKey = "INVALID_KEY" //The specified key is not valid (bad format, etc.) ResultKeyNotFound = "KEY_NOT_FOUND" //The naming system can't resolve the given name ResultPeerNotFound = "PEER_NOT_FOUND" //The peer cannot be found on the network ResultTimeout = "TIMEOUT" // Timeout while waiting for an event (e.g. peer answer) )
The Possible Results send by SAM
Variables ¶
var SAMsigTypes = []string{
"SIGNATURE_TYPE=DSA_SHA1",
"SIGNATURE_TYPE=ECDSA_SHA256_P256",
"SIGNATURE_TYPE=ECDSA_SHA384_P384",
"SIGNATURE_TYPE=ECDSA_SHA512_P521",
"SIGNATURE_TYPE=EdDSA_SHA512_Ed25519",
}
SAMsigTypes is a slice of the available signature types
var ValidSAMCommands = []string{
"HELLO",
"SESSION",
"STREAM",
}
Functions ¶
func NewReadHexLogger ¶ added in v0.32.4
NewReadHexLogger returns a reader that behaves like r except that it logs to stderr using ecoding/hex.
func NewReadLogger ¶ added in v0.32.4
NewReadLogger returns a reader that behaves like r except that it logs (using log.Print) each read to standard error, printing the prefix and the hexadecimal data written.
func NewWriteLogger ¶ added in v0.32.4
NewWriteLogger returns a writer that behaves like w except that it logs (using log.Printf) each write to standard error, printing the prefix and the hexadecimal data written.
func SetAddrMixed ¶
SetAddrMixed sets a clients's address in the form host, port(int)
func SetCloseIdle ¶
SetCloseIdle sets the tunnels to close after a specific amount of time
func SetCloseIdleTime ¶
SetCloseIdleTime sets the time in milliseconds to wait before closing tunnels
func SetCompression ¶
SetCompression sets the tunnels to close after a specific amount of time
func SetEncrypt ¶
SetEncrypt tells the router to use an encrypted leaseset
func SetFromPort ¶
SetFromPort sets the port of the client's SAM bridge using a string
func SetFromPortInt ¶
SetFromPortInt sets the port of the client's SAM bridge using a string
func SetInBackups ¶
SetInBackups sets the inbound tunnel backups
func SetInLength ¶
SetInLength sets the number of hops inbound
func SetInQuantity ¶
SetInQuantity sets the inbound tunnel quantity
func SetInVariance ¶
SetInVariance sets the variance of a number of hops inbound
func SetLeaseSetEncType ¶ added in v0.32.4
SetLeaseSetEncType tells the router to use an encrypted leaseset of a specific type. defaults to 4,0
func SetLocalDestination ¶
SetLocalDestination sets the local destination of the tunnel from a private key
func SetOutBackups ¶
SetOutBackups sets the inbound tunnel backups
func SetOutLength ¶
SetOutLength sets the number of hops outbound
func SetOutQuantity ¶
SetOutQuantity sets the outbound tunnel quantity
func SetOutVariance ¶
SetOutVariance sets the variance of a number of hops outbound
func SetPass ¶ added in v0.32.6
SetUser sets the password for authentication during the SAM HELLO phase
func SetPortInt ¶
SetPortInt sets the port of the client's SAM bridge using a string
func SetReduceIdle ¶
SetReduceIdle sets the created tunnels to be reduced during extended idle time to avoid excessive resource usage
func SetReduceIdleQuantity ¶
SetReduceIdleQuantity sets number of tunnels to keep alive during an extended idle period
func SetReduceIdleTime ¶
SetReduceIdleTime sets time to wait before the tunnel quantity is reduced
func SetSAMMaxVersion ¶ added in v0.32.4
func SetSAMMinVersion ¶ added in v0.32.4
func SetSignatureType ¶
SetSignatureType tells gosam to pass SAM a signature_type parameter with one of the following values:
"SIGNATURE_TYPE=DSA_SHA1", "SIGNATURE_TYPE=ECDSA_SHA256_P256", "SIGNATURE_TYPE=ECDSA_SHA384_P384", "SIGNATURE_TYPE=ECDSA_SHA512_P521", "SIGNATURE_TYPE=EdDSA_SHA512_Ed25519",
or an empty string
func SetToPortInt ¶
SetToPortInt sets the port of the client's SAM bridge using a string
func SetUnpublished ¶
SetUnpublished tells the router to not publish the client leaseset
func SetUser ¶ added in v0.32.6
SetUser sets the username for authentication during the SAM HELLO phase
func WrapRWC ¶ added in v0.32.4
func WrapRWC(c io.ReadWriteCloser) io.ReadWriteCloser
Types ¶
type Client ¶
type Client struct { SamConn net.Conn // Control socket SamDGConn net.PacketConn // Datagram socket // contains filtered or unexported fields }
A Client represents a single Connection to the SAM bridge
func NewClientFromOptions ¶
NewClientFromOptions creates a new client, connecting to a specified port
func NewDefaultClient ¶
NewDefaultClient creates a new client, connecting to the default host:port at localhost:7656
func (*Client) Accept ¶
Accept accepts a connection on a listening goSam.Client(Implements net.Listener) or, if the connection isn't listening yet, just calls AcceptI2P for compatibility with older versions.
func (*Client) CreateDatagramSession ¶ added in v0.32.4
CreateDatagramSession creates a new DATAGRAM Session. Returns the Id for the new Client.
func (*Client) CreateRawSession ¶ added in v0.32.4
CreateRawSession creates a new RAW Session. Returns the Id for the new Client.
func (*Client) CreateSession ¶ added in v0.32.4
CreateSession creates a new Session of type style, with an optional destination. an empty destination is interpreted as "TRANSIENT" Returns the destination for the new Client or an error.
func (*Client) CreateStreamSession ¶
CreateStreamSession creates a new STREAM Session. Returns the Id for the new Client.
func (*Client) Destination ¶
Destination returns the full destination of the local tunnel
func (*Client) DialContext ¶
DialContext implements the net.DialContext function and can be used for http.Transport
func (*Client) DialContextFree ¶ added in v0.32.4
DialContextFree implements the net.Dial function and can be used for http.Transport
func (*Client) DialDatagramContextFree ¶ added in v0.32.4
func (c *Client) DialDatagramContextFree(addr string) (*DatagramConn, error)
DialDatagramContextFree is a "Dialer" for "Client-Like" Datagram connections. It is also not finished. If you need datagram support right now, use sam3.
func (*Client) DialStreamingContextFree ¶ added in v0.32.4
DialStreamingContextFree is a "Dialer" for "Client-Like" Streaming connections.
func (*Client) Listen ¶
Listen creates a new Client and returns a net.listener which *must* be started with Accept
func (*Client) ListenI2P ¶
ListenI2P creates a new Client and returns a net.listener which *must* be started with Accept
func (*Client) NewClient ¶
NewClient generates an exact copy of the client with the same options, but re-does all the handshaky business so that Dial can pick up right where it left off, should the need arise.
func (*Client) NewDestination ¶ added in v0.32.4
Generate a new destination and return the base64 encoded string
func (*Client) PrivateAddr ¶ added in v0.32.6
LocalKeys returns the local keys of the client as a fully-fledged i2pkeys.I2PKeys
func (*Client) RemoveAuthUser ¶ added in v0.32.6
func (*Client) SetupAuth ¶ added in v0.32.6
SetupAuth sends the AUTH ENABLE command and immediately sets up a new Username and Password from the arguments
func (*Client) StreamAccept ¶
StreamAccept asks SAM to accept a TCP-Like connection
func (*Client) StreamConnect ¶
StreamConnect asks SAM for a TCP-Like connection to dest, has to be called on a new Client
func (*Client) TeardownAuth ¶ added in v0.32.6
TeardownAuth sends the AUTH DISABLE command but does not remove the Username and Password from the client PasswordManager
type Conn ¶ added in v0.32.2
type Conn struct { RWC // contains filtered or unexported fields }
Conn Read data from the connection, writes data to te connection and logs the data in-between.
func WrapPacketConn ¶ added in v0.32.6
WrapConn wraps a net.PacketConn in a DatagramConn.
func (*Conn) RemoteAddr ¶ added in v0.32.2
RemoteAddr returns the remote address of the connection.
func (*Conn) SetDeadline ¶ added in v0.32.2
SetDeadline sets the read and write deadlines associated with the connection
func (*Conn) SetReadDeadline ¶ added in v0.32.2
SetReadDeadline sets the read deadline associated with the connection
type DatagramConn ¶ added in v0.32.4
DatagramConn
func (*DatagramConn) Close ¶ added in v0.32.4
func (d *DatagramConn) Close() error
func (*DatagramConn) LocalAddr ¶ added in v0.32.4
func (d *DatagramConn) LocalAddr() net.Addr
func (*DatagramConn) Read ¶ added in v0.32.4
func (d *DatagramConn) Read(b []byte) (n int, err error)
func (*DatagramConn) RemoteAddr ¶ added in v0.32.4
func (d *DatagramConn) RemoteAddr() net.Addr
func (*DatagramConn) SetDeadline ¶ added in v0.32.4
func (d *DatagramConn) SetDeadline(t time.Time) error
func (*DatagramConn) SetReadDeadline ¶ added in v0.32.4
func (d *DatagramConn) SetReadDeadline(t time.Time) error
func (*DatagramConn) SetWriteDeadline ¶ added in v0.32.4
func (d *DatagramConn) SetWriteDeadline(t time.Time) error
type Reply ¶
Reply is the parsed result of a SAM command, containing a map of all the key-value pairs
type ReplyError ¶
A ReplyError is a custom error type, containing the Result and full Reply
func (ReplyError) Error ¶
func (r ReplyError) Error() string