From a53acecb87b62c941a7e1470d0f7335a84feddba Mon Sep 17 00:00:00 2001 From: eyedeekay Date: Thu, 29 May 2025 19:44:45 -0400 Subject: [PATCH] godoc --- .gitignore | 2 +- DOC.md | 1251 +++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 4 +- README.md | 6 +- common/DOC.md | 944 +++++++++++++++++++++++++++++++++++ datagram/DOC.md | 353 +++++++++++++ primary/DOC.md | 6 + raw/DOC.md | 341 +++++++++++++ stream/DOC.md | 252 ++++++++++ 9 files changed, 3154 insertions(+), 5 deletions(-) create mode 100644 DOC.md create mode 100644 common/DOC.md create mode 100644 datagram/DOC.md create mode 100644 primary/DOC.md create mode 100644 raw/DOC.md create mode 100644 stream/DOC.md diff --git a/.gitignore b/.gitignore index 1050bb5..d0ffe8c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ review.md SAMv3.md testplan.md err -/*.log \ No newline at end of file +/*.log diff --git a/DOC.md b/DOC.md new file mode 100644 index 0000000..11c70aa --- /dev/null +++ b/DOC.md @@ -0,0 +1,1251 @@ +# sam3 +-- + import "github.com/go-i2p/go-sam-go" + +Package sam3 provides a compatibility layer for the go-i2p/sam3 library using +go-sam-go as the backend + +## Usage + +```go +const ( + Sig_NONE = "SIGNATURE_TYPE=EdDSA_SHA512_Ed25519" + Sig_DSA_SHA1 = "SIGNATURE_TYPE=DSA_SHA1" + Sig_ECDSA_SHA256_P256 = "SIGNATURE_TYPE=ECDSA_SHA256_P256" + Sig_ECDSA_SHA384_P384 = "SIGNATURE_TYPE=ECDSA_SHA384_P384" + Sig_ECDSA_SHA512_P521 = "SIGNATURE_TYPE=ECDSA_SHA512_P521" + Sig_EdDSA_SHA512_Ed25519 = "SIGNATURE_TYPE=EdDSA_SHA512_Ed25519" +) +``` +Constants from original sam3 + +```go +var ( + Options_Humongous = []string{ + "inbound.length=3", "outbound.length=3", + "inbound.lengthVariance=1", "outbound.lengthVariance=1", + "inbound.backupQuantity=3", "outbound.backupQuantity=3", + "inbound.quantity=6", "outbound.quantity=6", + } + + Options_Large = []string{ + "inbound.length=3", "outbound.length=3", + "inbound.lengthVariance=1", "outbound.lengthVariance=1", + "inbound.backupQuantity=1", "outbound.backupQuantity=1", + "inbound.quantity=4", "outbound.quantity=4", + } + + Options_Wide = []string{ + "inbound.length=1", "outbound.length=1", + "inbound.lengthVariance=1", "outbound.lengthVariance=1", + "inbound.backupQuantity=2", "outbound.backupQuantity=2", + "inbound.quantity=3", "outbound.quantity=3", + } + + Options_Medium = []string{ + "inbound.length=3", "outbound.length=3", + "inbound.lengthVariance=1", "outbound.lengthVariance=1", + "inbound.backupQuantity=0", "outbound.backupQuantity=0", + "inbound.quantity=2", "outbound.quantity=2", + } + + Options_Default = []string{ + "inbound.length=3", "outbound.length=3", + "inbound.lengthVariance=0", "outbound.lengthVariance=0", + "inbound.backupQuantity=1", "outbound.backupQuantity=1", + "inbound.quantity=1", "outbound.quantity=1", + } + + Options_Small = []string{ + "inbound.length=3", "outbound.length=3", + "inbound.lengthVariance=1", "outbound.lengthVariance=1", + "inbound.backupQuantity=0", "outbound.backupQuantity=0", + "inbound.quantity=1", "outbound.quantity=1", + } + + Options_Warning_ZeroHop = []string{ + "inbound.length=0", "outbound.length=0", + "inbound.lengthVariance=0", "outbound.lengthVariance=0", + "inbound.backupQuantity=0", "outbound.backupQuantity=0", + "inbound.quantity=2", "outbound.quantity=2", + } +) +``` +Predefined option sets (keeping your existing definitions) + +```go +var ( + PrimarySessionSwitch string = PrimarySessionString() + SAM_HOST = getEnv("sam_host", "127.0.0.1") + SAM_PORT = getEnv("sam_port", "7656") +) +``` +Global variables from original sam3 + +#### func ConvertOptionsToSlice + +```go +func ConvertOptionsToSlice(opts Options) []string +``` +Additional utility functions that may be needed for compatibility + +#### func ExtractDest + +```go +func ExtractDest(input string) string +``` +ExtractDest extracts destination from input + +#### func ExtractPairInt + +```go +func ExtractPairInt(input, value string) int +``` +ExtractPairInt extracts integer value from key=value pair + +#### func ExtractPairString + +```go +func ExtractPairString(input, value string) string +``` +ExtractPairString extracts string value from key=value pair + +#### func GenerateOptionString + +```go +func GenerateOptionString(opts []string) string +``` +GenerateOptionString generates option string from slice + +#### func GetSAM3Logger + +```go +func GetSAM3Logger() *logrus.Logger +``` +GetSAM3Logger returns the initialized logger + +#### func IgnorePortError + +```go +func IgnorePortError(err error) error +``` +IgnorePortError ignores port-related errors + +#### func InitializeSAM3Logger + +```go +func InitializeSAM3Logger() +``` +InitializeSAM3Logger initializes the logger + +#### func PrimarySessionString + +```go +func PrimarySessionString() string +``` +PrimarySessionString returns primary session string + +#### func RandString + +```go +func RandString() string +``` +RandString generates a random string + +#### func SAMDefaultAddr + +```go +func SAMDefaultAddr(fallforward string) string +``` +SAMDefaultAddr returns default SAM address + +#### func SetAccessListType + +```go +func SetAccessListType(s string) func(*I2PConfig) error +``` + +#### func SetCloseIdleTime + +```go +func SetCloseIdleTime(s string) func(*I2PConfig) error +``` + +#### func SetInAllowZeroHop + +```go +func SetInAllowZeroHop(s string) func(*I2PConfig) error +``` +Configuration option setters for all the missing Set* functions + +#### func SetInBackupQuantity + +```go +func SetInBackupQuantity(s string) func(*I2PConfig) error +``` + +#### func SetInLength + +```go +func SetInLength(s string) func(*I2PConfig) error +``` + +#### func SetInQuantity + +```go +func SetInQuantity(s string) func(*I2PConfig) error +``` + +#### func SetInVariance + +```go +func SetInVariance(s string) func(*I2PConfig) error +``` + +#### func SetOutAllowZeroHop + +```go +func SetOutAllowZeroHop(s string) func(*I2PConfig) error +``` + +#### func SetOutBackupQuantity + +```go +func SetOutBackupQuantity(s string) func(*I2PConfig) error +``` + +#### func SetOutLength + +```go +func SetOutLength(s string) func(*I2PConfig) error +``` + +#### func SetOutQuantity + +```go +func SetOutQuantity(s string) func(*I2PConfig) error +``` + +#### func SetOutVariance + +```go +func SetOutVariance(s string) func(*I2PConfig) error +``` + +#### func SetReduceIdleTime + +```go +func SetReduceIdleTime(s string) func(*I2PConfig) error +``` + +#### func SetUseCompression + +```go +func SetUseCompression(s string) func(*I2PConfig) error +``` + +#### type DatagramSession + +```go +type DatagramSession struct { +} +``` + +DatagramSession implements net.PacketConn for I2P datagrams + +#### func (*DatagramSession) Accept + +```go +func (s *DatagramSession) Accept() (net.Conn, error) +``` +Accept accepts connections (not applicable for datagrams) + +#### func (*DatagramSession) Addr + +```go +func (s *DatagramSession) Addr() net.Addr +``` +Addr returns the session address + +#### func (*DatagramSession) B32 + +```go +func (s *DatagramSession) B32() string +``` +B32 returns the base32 address + +#### func (*DatagramSession) Close + +```go +func (s *DatagramSession) Close() error +``` +Close closes the datagram session + +#### func (*DatagramSession) Dial + +```go +func (s *DatagramSession) Dial(net string, addr string) (*DatagramSession, error) +``` +Dial dials a connection (returns self for datagrams) + +#### func (*DatagramSession) DialI2PRemote + +```go +func (s *DatagramSession) DialI2PRemote(net string, addr net.Addr) (*DatagramSession, error) +``` +DialI2PRemote dials to I2P remote + +#### func (*DatagramSession) DialRemote + +```go +func (s *DatagramSession) DialRemote(net, addr string) (net.PacketConn, error) +``` +DialRemote dials to remote address + +#### func (*DatagramSession) LocalAddr + +```go +func (s *DatagramSession) LocalAddr() net.Addr +``` +LocalAddr returns the local address + +#### func (*DatagramSession) LocalI2PAddr + +```go +func (s *DatagramSession) LocalI2PAddr() i2pkeys.I2PAddr +``` +LocalI2PAddr returns the I2P destination + +#### func (*DatagramSession) Lookup + +```go +func (s *DatagramSession) Lookup(name string) (a net.Addr, err error) +``` +Lookup performs name lookup + +#### func (*DatagramSession) Read + +```go +func (s *DatagramSession) Read(b []byte) (n int, err error) +``` +Read reads from the session + +#### func (*DatagramSession) ReadFrom + +```go +func (s *DatagramSession) ReadFrom(b []byte) (n int, addr net.Addr, err error) +``` +ReadFrom reads a datagram from the session + +#### func (*DatagramSession) RemoteAddr + +```go +func (s *DatagramSession) RemoteAddr() net.Addr +``` +RemoteAddr returns the remote address + +#### func (*DatagramSession) SetDeadline + +```go +func (s *DatagramSession) SetDeadline(t time.Time) error +``` +SetDeadline sets read and write deadlines + +#### func (*DatagramSession) SetReadDeadline + +```go +func (s *DatagramSession) SetReadDeadline(t time.Time) error +``` +SetReadDeadline sets read deadline + +#### func (*DatagramSession) SetWriteBuffer + +```go +func (s *DatagramSession) SetWriteBuffer(bytes int) error +``` +SetWriteBuffer sets write buffer size + +#### func (*DatagramSession) SetWriteDeadline + +```go +func (s *DatagramSession) SetWriteDeadline(t time.Time) error +``` +SetWriteDeadline sets write deadline + +#### func (*DatagramSession) Write + +```go +func (s *DatagramSession) Write(b []byte) (int, error) +``` +Write writes to the session + +#### func (*DatagramSession) WriteTo + +```go +func (s *DatagramSession) WriteTo(b []byte, addr net.Addr) (n int, err error) +``` +WriteTo writes a datagram to the specified address + +#### type I2PConfig + +```go +type I2PConfig struct { + *common.I2PConfig +} +``` + +I2PConfig manages I2P configuration options + +#### func NewConfig + +```go +func NewConfig(opts ...func(*I2PConfig) error) (*I2PConfig, error) +``` +NewConfig creates a new I2PConfig + +#### func (*I2PConfig) DestinationKey + +```go +func (f *I2PConfig) DestinationKey() string +``` + +#### func (*I2PConfig) ID + +```go +func (f *I2PConfig) ID() string +``` + +#### func (*I2PConfig) MaxSAM + +```go +func (f *I2PConfig) MaxSAM() string +``` + +#### func (*I2PConfig) MinSAM + +```go +func (f *I2PConfig) MinSAM() string +``` + +#### func (*I2PConfig) Print + +```go +func (f *I2PConfig) Print() []string +``` + +#### func (*I2PConfig) Reduce + +```go +func (f *I2PConfig) Reduce() string +``` + +#### func (*I2PConfig) Reliability + +```go +func (f *I2PConfig) Reliability() string +``` + +#### func (*I2PConfig) SAMAddress + +```go +func (f *I2PConfig) SAMAddress() string +``` + +#### func (*I2PConfig) Sam + +```go +func (f *I2PConfig) Sam() string +``` + +#### func (*I2PConfig) SessionStyle + +```go +func (f *I2PConfig) SessionStyle() string +``` + +#### func (*I2PConfig) SetSAMAddress + +```go +func (f *I2PConfig) SetSAMAddress(addr string) +``` +All the configuration method forwards + +#### func (*I2PConfig) SignatureType + +```go +func (f *I2PConfig) SignatureType() string +``` + +#### func (*I2PConfig) ToPort + +```go +func (f *I2PConfig) ToPort() string +``` + +#### type Option + +```go +type Option func(*SAMEmit) error +``` + +Option is a functional option for SAMEmit + +#### type Options + +```go +type Options map[string]string +``` + +Options represents a map of configuration options + +#### func ConvertSliceToOptions + +```go +func ConvertSliceToOptions(slice []string) Options +``` + +#### func (Options) AsList + +```go +func (opts Options) AsList() (ls []string) +``` +AsList returns options as a list of strings + +#### type PrimarySession + +```go +type PrimarySession struct { + Timeout time.Duration + Deadline time.Time + Config SAMEmit +} +``` + +PrimarySession represents a primary session + +#### func (*PrimarySession) Addr + +```go +func (ss *PrimarySession) Addr() i2pkeys.I2PAddr +``` +Addr returns the I2P address + +#### func (*PrimarySession) Close + +```go +func (ss *PrimarySession) Close() error +``` +Close closes the session + +#### func (*PrimarySession) Dial + +```go +func (sam *PrimarySession) Dial(network, addr string) (net.Conn, error) +``` +Dial implements net.Dialer + +#### func (*PrimarySession) DialTCP + +```go +func (sam *PrimarySession) DialTCP(network string, laddr, raddr net.Addr) (net.Conn, error) +``` +DialTCP implements x/dialer + +#### func (*PrimarySession) DialTCPI2P + +```go +func (sam *PrimarySession) DialTCPI2P(network string, laddr, raddr string) (net.Conn, error) +``` +DialTCPI2P dials TCP over I2P + +#### func (*PrimarySession) DialUDP + +```go +func (sam *PrimarySession) DialUDP(network string, laddr, raddr net.Addr) (net.PacketConn, error) +``` +DialUDP implements x/dialer + +#### func (*PrimarySession) DialUDPI2P + +```go +func (sam *PrimarySession) DialUDPI2P(network, laddr, raddr string) (*DatagramSession, error) +``` +DialUDPI2P dials UDP over I2P + +#### func (*PrimarySession) From + +```go +func (ss *PrimarySession) From() string +``` +From returns from port + +#### func (*PrimarySession) ID + +```go +func (ss *PrimarySession) ID() string +``` +ID returns the session ID + +#### func (*PrimarySession) Keys + +```go +func (ss *PrimarySession) Keys() i2pkeys.I2PKeys +``` +Keys returns the session keys + +#### func (*PrimarySession) LocalAddr + +```go +func (ss *PrimarySession) LocalAddr() net.Addr +``` +LocalAddr returns local address + +#### func (*PrimarySession) Lookup + +```go +func (s *PrimarySession) Lookup(name string) (a net.Addr, err error) +``` +Lookup performs name lookup + +#### func (*PrimarySession) NewDatagramSubSession + +```go +func (s *PrimarySession) NewDatagramSubSession(id string, udpPort int) (*DatagramSession, error) +``` +NewDatagramSubSession creates a new datagram sub-session + +#### func (*PrimarySession) NewRawSubSession + +```go +func (s *PrimarySession) NewRawSubSession(id string, udpPort int) (*RawSession, error) +``` +NewRawSubSession creates a new raw sub-session + +#### func (*PrimarySession) NewStreamSubSession + +```go +func (sam *PrimarySession) NewStreamSubSession(id string) (*StreamSession, error) +``` +NewStreamSubSession creates a new stream sub-session + +#### func (*PrimarySession) NewStreamSubSessionWithPorts + +```go +func (sam *PrimarySession) NewStreamSubSessionWithPorts(id, from, to string) (*StreamSession, error) +``` +NewStreamSubSessionWithPorts creates a new stream sub-session with ports + +#### func (*PrimarySession) NewUniqueStreamSubSession + +```go +func (sam *PrimarySession) NewUniqueStreamSubSession(id string) (*StreamSession, error) +``` +NewUniqueStreamSubSession creates a unique stream sub-session + +#### func (*PrimarySession) Resolve + +```go +func (sam *PrimarySession) Resolve(network, addr string) (net.Addr, error) +``` +Resolve resolves network address + +#### func (*PrimarySession) ResolveTCPAddr + +```go +func (sam *PrimarySession) ResolveTCPAddr(network, dest string) (net.Addr, error) +``` +ResolveTCPAddr resolves TCP address + +#### func (*PrimarySession) ResolveUDPAddr + +```go +func (sam *PrimarySession) ResolveUDPAddr(network, dest string) (net.Addr, error) +``` +ResolveUDPAddr resolves UDP address + +#### func (*PrimarySession) SignatureType + +```go +func (ss *PrimarySession) SignatureType() string +``` +SignatureType returns signature type + +#### func (*PrimarySession) To + +```go +func (ss *PrimarySession) To() string +``` +To returns to port + +#### type RawSession + +```go +type RawSession struct { +} +``` + +RawSession provides raw datagram messaging + +#### func (*RawSession) Close + +```go +func (s *RawSession) Close() error +``` +Close closes the raw session + +#### func (*RawSession) LocalAddr + +```go +func (s *RawSession) LocalAddr() i2pkeys.I2PAddr +``` +LocalAddr returns the local I2P destination + +#### func (*RawSession) Read + +```go +func (s *RawSession) Read(b []byte) (n int, err error) +``` +Read reads one raw datagram + +#### func (*RawSession) SetDeadline + +```go +func (s *RawSession) SetDeadline(t time.Time) error +``` +SetDeadline sets read and write deadlines + +#### func (*RawSession) SetReadDeadline + +```go +func (s *RawSession) SetReadDeadline(t time.Time) error +``` +SetReadDeadline sets read deadline + +#### func (*RawSession) SetWriteDeadline + +```go +func (s *RawSession) SetWriteDeadline(t time.Time) error +``` +SetWriteDeadline sets write deadline + +#### func (*RawSession) WriteTo + +```go +func (s *RawSession) WriteTo(b []byte, addr i2pkeys.I2PAddr) (n int, err error) +``` +WriteTo sends one raw datagram to the destination + +#### type SAM + +```go +type SAM struct { + Config SAMEmit +} +``` + +SAM represents the main controller for I2P router's SAM bridge + +#### func NewSAM + +```go +func NewSAM(address string) (*SAM, error) +``` +NewSAM creates a new controller for the I2P routers SAM bridge + +#### func (*SAM) Close + +```go +func (sam *SAM) Close() error +``` +Close closes this sam session + +#### func (*SAM) EnsureKeyfile + +```go +func (sam *SAM) EnsureKeyfile(fname string) (keys i2pkeys.I2PKeys, err error) +``` +EnsureKeyfile ensures keyfile exists + +#### func (*SAM) Keys + +```go +func (sam *SAM) Keys() (k *i2pkeys.I2PKeys) +``` +Keys returns the keys associated with this SAM instance + +#### func (*SAM) Lookup + +```go +func (sam *SAM) Lookup(name string) (i2pkeys.I2PAddr, error) +``` +Lookup performs a name lookup + +#### func (*SAM) NewDatagramSession + +```go +func (s *SAM) NewDatagramSession(id string, keys i2pkeys.I2PKeys, options []string, udpPort int) (*DatagramSession, error) +``` +NewDatagramSession creates a new datagram session + +#### func (*SAM) NewKeys + +```go +func (sam *SAM) NewKeys(sigType ...string) (i2pkeys.I2PKeys, error) +``` +NewKeys creates the I2P-equivalent of an IP address + +#### func (*SAM) NewPrimarySession + +```go +func (sam *SAM) NewPrimarySession(id string, keys i2pkeys.I2PKeys, options []string) (*PrimarySession, error) +``` +NewPrimarySession creates a new PrimarySession + +#### func (*SAM) NewPrimarySessionWithSignature + +```go +func (sam *SAM) NewPrimarySessionWithSignature(id string, keys i2pkeys.I2PKeys, options []string, sigType string) (*PrimarySession, error) +``` +NewPrimarySessionWithSignature creates a new PrimarySession with signature + +#### func (*SAM) NewRawSession + +```go +func (s *SAM) NewRawSession(id string, keys i2pkeys.I2PKeys, options []string, udpPort int) (*RawSession, error) +``` +NewRawSession creates a new raw session + +#### func (*SAM) NewStreamSession + +```go +func (sam *SAM) NewStreamSession(id string, keys i2pkeys.I2PKeys, options []string) (*StreamSession, error) +``` +NewStreamSession creates a new StreamSession + +#### func (*SAM) NewStreamSessionWithSignature + +```go +func (sam *SAM) NewStreamSessionWithSignature(id string, keys i2pkeys.I2PKeys, options []string, sigType string) (*StreamSession, error) +``` +NewStreamSessionWithSignature creates a new StreamSession with custom signature + +#### func (*SAM) NewStreamSessionWithSignatureAndPorts + +```go +func (sam *SAM) NewStreamSessionWithSignatureAndPorts(id, from, to string, keys i2pkeys.I2PKeys, options []string, sigType string) (*StreamSession, error) +``` +NewStreamSessionWithSignatureAndPorts creates a new StreamSession with signature +and ports + +#### func (*SAM) ReadKeys + +```go +func (sam *SAM) ReadKeys(r io.Reader) (err error) +``` +ReadKeys reads public/private keys from an io.Reader + +#### type SAMConn + +```go +type SAMConn struct { +} +``` + +SAMConn implements net.Conn for I2P connections + +#### func (*SAMConn) Close + +```go +func (sc *SAMConn) Close() error +``` +Close closes the connection + +#### func (*SAMConn) LocalAddr + +```go +func (sc *SAMConn) LocalAddr() net.Addr +``` +LocalAddr returns the local address + +#### func (*SAMConn) Read + +```go +func (sc *SAMConn) Read(buf []byte) (int, error) +``` +Read reads data from the connection + +#### func (*SAMConn) RemoteAddr + +```go +func (sc *SAMConn) RemoteAddr() net.Addr +``` +RemoteAddr returns the remote address + +#### func (*SAMConn) SetDeadline + +```go +func (sc *SAMConn) SetDeadline(t time.Time) error +``` +SetDeadline sets read and write deadlines + +#### func (*SAMConn) SetReadDeadline + +```go +func (sc *SAMConn) SetReadDeadline(t time.Time) error +``` +SetReadDeadline sets read deadline + +#### func (*SAMConn) SetWriteDeadline + +```go +func (sc *SAMConn) SetWriteDeadline(t time.Time) error +``` +SetWriteDeadline sets write deadline + +#### func (*SAMConn) Write + +```go +func (sc *SAMConn) Write(buf []byte) (int, error) +``` +Write writes data to the connection + +#### type SAMEmit + +```go +type SAMEmit struct { + I2PConfig +} +``` + +SAMEmit handles SAM protocol message generation + +#### func NewEmit + +```go +func NewEmit(opts ...func(*SAMEmit) error) (*SAMEmit, error) +``` +NewEmit creates a new SAMEmit + +#### func (*SAMEmit) Accept + +```go +func (e *SAMEmit) Accept() string +``` +Accept generates accept message + +#### func (*SAMEmit) AcceptBytes + +```go +func (e *SAMEmit) AcceptBytes() []byte +``` +AcceptBytes generates accept message as bytes + +#### func (*SAMEmit) Connect + +```go +func (e *SAMEmit) Connect(dest string) string +``` +Connect generates connect message + +#### func (*SAMEmit) ConnectBytes + +```go +func (e *SAMEmit) ConnectBytes(dest string) []byte +``` +ConnectBytes generates connect message as bytes + +#### func (*SAMEmit) Create + +```go +func (e *SAMEmit) Create() string +``` +Create generates session create message + +#### func (*SAMEmit) CreateBytes + +```go +func (e *SAMEmit) CreateBytes() []byte +``` +CreateBytes generates session create message as bytes + +#### func (*SAMEmit) GenerateDestination + +```go +func (e *SAMEmit) GenerateDestination() string +``` +GenerateDestination generates destination message + +#### func (*SAMEmit) GenerateDestinationBytes + +```go +func (e *SAMEmit) GenerateDestinationBytes() []byte +``` +GenerateDestinationBytes generates destination message as bytes + +#### func (*SAMEmit) Hello + +```go +func (e *SAMEmit) Hello() string +``` +Hello generates hello message + +#### func (*SAMEmit) HelloBytes + +```go +func (e *SAMEmit) HelloBytes() []byte +``` +HelloBytes generates hello message as bytes + +#### func (*SAMEmit) Lookup + +```go +func (e *SAMEmit) Lookup(name string) string +``` +Lookup generates lookup message + +#### func (*SAMEmit) LookupBytes + +```go +func (e *SAMEmit) LookupBytes(name string) []byte +``` +LookupBytes generates lookup message as bytes + +#### func (*SAMEmit) SamOptionsString + +```go +func (e *SAMEmit) SamOptionsString() string +``` +SamOptionsString returns SAM options as string + +#### type SAMResolver + +```go +type SAMResolver struct { + *SAM +} +``` + +SAMResolver provides name resolution functionality + +#### func NewFullSAMResolver + +```go +func NewFullSAMResolver(address string) (*SAMResolver, error) +``` +NewFullSAMResolver creates a new full SAMResolver + +#### func NewSAMResolver + +```go +func NewSAMResolver(parent *SAM) (*SAMResolver, error) +``` +NewSAMResolver creates a new SAMResolver from existing SAM + +#### func (*SAMResolver) Resolve + +```go +func (sam *SAMResolver) Resolve(name string) (i2pkeys.I2PAddr, error) +``` +Resolve performs a lookup + +#### type StreamListener + +```go +type StreamListener struct { +} +``` + +StreamListener implements net.Listener for I2P streams + +#### func (*StreamListener) Accept + +```go +func (l *StreamListener) Accept() (net.Conn, error) +``` +Accept accepts new inbound connections + +#### func (*StreamListener) AcceptI2P + +```go +func (l *StreamListener) AcceptI2P() (*SAMConn, error) +``` +AcceptI2P accepts a new inbound I2P connection + +#### func (*StreamListener) Addr + +```go +func (l *StreamListener) Addr() net.Addr +``` +Addr returns the listener's address + +#### func (*StreamListener) Close + +```go +func (l *StreamListener) Close() error +``` +Close closes the listener + +#### func (*StreamListener) From + +```go +func (l *StreamListener) From() string +``` +From returns the from port + +#### func (*StreamListener) To + +```go +func (l *StreamListener) To() string +``` +To returns the to port + +#### type StreamSession + +```go +type StreamSession struct { + Timeout time.Duration + Deadline time.Time +} +``` + +StreamSession represents a streaming session + +#### func (*StreamSession) Addr + +```go +func (s *StreamSession) Addr() i2pkeys.I2PAddr +``` +Addr returns the I2P destination address + +#### func (*StreamSession) Close + +```go +func (s *StreamSession) Close() error +``` +Close closes the session + +#### func (*StreamSession) Dial + +```go +func (s *StreamSession) Dial(n, addr string) (c net.Conn, err error) +``` +Dial establishes a connection to an address + +#### func (*StreamSession) DialContext + +```go +func (s *StreamSession) DialContext(ctx context.Context, n, addr string) (net.Conn, error) +``` +DialContext establishes a connection with context + +#### func (*StreamSession) DialContextI2P + +```go +func (s *StreamSession) DialContextI2P(ctx context.Context, n, addr string) (*SAMConn, error) +``` +DialContextI2P establishes an I2P connection with context + +#### func (*StreamSession) DialI2P + +```go +func (s *StreamSession) DialI2P(addr i2pkeys.I2PAddr) (*SAMConn, error) +``` +DialI2P dials to an I2P destination + +#### func (*StreamSession) From + +```go +func (s *StreamSession) From() string +``` +From returns the from port + +#### func (*StreamSession) ID + +```go +func (s *StreamSession) ID() string +``` +ID returns the local tunnel name + +#### func (*StreamSession) Keys + +```go +func (s *StreamSession) Keys() i2pkeys.I2PKeys +``` +Keys returns the keys associated with the session + +#### func (*StreamSession) Listen + +```go +func (s *StreamSession) Listen() (*StreamListener, error) +``` +Listen creates a new stream listener + +#### func (*StreamSession) LocalAddr + +```go +func (s *StreamSession) LocalAddr() net.Addr +``` +LocalAddr returns the local address + +#### func (*StreamSession) Lookup + +```go +func (s *StreamSession) Lookup(name string) (i2pkeys.I2PAddr, error) +``` +Lookup performs name lookup + +#### func (*StreamSession) Read + +```go +func (s *StreamSession) Read(buf []byte) (int, error) +``` +Read reads data from the stream + +#### func (*StreamSession) RemoteAddr + +```go +func (s *StreamSession) RemoteAddr() net.Addr +``` +RemoteAddr returns the remote address + +#### func (*StreamSession) SetDeadline + +```go +func (s *StreamSession) SetDeadline(t time.Time) error +``` +SetDeadline sets read and write deadlines + +#### func (*StreamSession) SetReadDeadline + +```go +func (s *StreamSession) SetReadDeadline(t time.Time) error +``` +SetReadDeadline sets read deadline + +#### func (*StreamSession) SetWriteDeadline + +```go +func (s *StreamSession) SetWriteDeadline(t time.Time) error +``` +SetWriteDeadline sets write deadline + +#### func (*StreamSession) SignatureType + +```go +func (s *StreamSession) SignatureType() string +``` +SignatureType returns the signature type + +#### func (*StreamSession) To + +```go +func (s *StreamSession) To() string +``` +To returns the to port + +#### func (*StreamSession) Write + +```go +func (s *StreamSession) Write(data []byte) (int, error) +``` +Write sends data over the stream diff --git a/Makefile b/Makefile index f503936..947f73f 100644 --- a/Makefile +++ b/Makefile @@ -25,10 +25,12 @@ test: #make raw-test #make primary-test - test-logs: make common-test 2> common-err.log 1> common-out.log; cat common-err.log common-out.log make stream-test 2> stream-err.log 1> stream-out.log; cat stream-err.log stream-out.log make datagram-test 2> datagram-err.log 1> datagram-out.log; cat datagram-err.log datagram-out.log #make raw-test 2> raw-err.log 1> raw-out.log; cat raw-err.log raw-out.log #make primary-test 2> primary-err.log 1> primary-out.log; cat primary-err.log primary-out.log + +godoc: + find ./*/ -type d -exec godocdown --output={}/DOC.md {} \; \ No newline at end of file diff --git a/README.md b/README.md index c068250..c0d4f1b 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,9 @@ A pure-Go implementation of SAMv3.3 (Simple Anonymous Messaging) for I2P, focused on maintainability and clean architecture. This project is forked from `github.com/go-i2p/sam3` with reorganized code structure. -**WARNING: This is a new package and nothing works yet.** -**BUT, the point of it is to have carefully designed fixes to sam3's rough edges, so the API should be stable** -**It should be ready soon but right now it's broke.** +**WARNING: This is a new package. Streaming works and so does some of datagrams.** +**The API should not change much.** +**It needs more people looking at it.** ## 📦 Installation diff --git a/common/DOC.md b/common/DOC.md new file mode 100644 index 0000000..97e6dbb --- /dev/null +++ b/common/DOC.md @@ -0,0 +1,944 @@ +# common +-- + import "github.com/go-i2p/go-sam-go/common" + + +## Usage + +```go +const ( + DEFAULT_SAM_MIN = "3.1" + DEFAULT_SAM_MAX = "3.3" +) +``` + +```go +const ( + SESSION_OK = "SESSION STATUS RESULT=OK DESTINATION=" + SESSION_DUPLICATE_ID = "SESSION STATUS RESULT=DUPLICATED_ID\n" + SESSION_DUPLICATE_DEST = "SESSION STATUS RESULT=DUPLICATED_DEST\n" + SESSION_INVALID_KEY = "SESSION STATUS RESULT=INVALID_KEY\n" + SESSION_I2P_ERROR = "SESSION STATUS RESULT=I2P_ERROR MESSAGE=" +) +``` + +```go +const ( + SIG_NONE = "SIGNATURE_TYPE=EdDSA_SHA512_Ed25519" + SIG_DSA_SHA1 = "SIGNATURE_TYPE=DSA_SHA1" + SIG_ECDSA_SHA256_P256 = "SIGNATURE_TYPE=ECDSA_SHA256_P256" + SIG_ECDSA_SHA384_P384 = "SIGNATURE_TYPE=ECDSA_SHA384_P384" + SIG_ECDSA_SHA512_P521 = "SIGNATURE_TYPE=ECDSA_SHA512_P521" + SIG_EdDSA_SHA512_Ed25519 = "SIGNATURE_TYPE=EdDSA_SHA512_Ed25519" + // Add a default constant that points to the recommended secure signature type + SIG_DEFAULT = SIG_EdDSA_SHA512_Ed25519 +) +``` + +```go +const ( + SAM_RESULT_OK = "RESULT=OK" + SAM_RESULT_INVALID_KEY = "RESULT=INVALID_KEY" + SAM_RESULT_KEY_NOT_FOUND = "RESULT=KEY_NOT_FOUND" +) +``` + +```go +const ( + HELLO_REPLY_OK = "HELLO REPLY RESULT=OK" + HELLO_REPLY_NOVERSION = "HELLO REPLY RESULT=NOVERSION\n" +) +``` + +```go +const ( + SESSION_STYLE_STREAM = "STREAM" + SESSION_STYLE_DATAGRAM = "DATAGRAM" + SESSION_STYLE_RAW = "RAW" +) +``` + +```go +const ( + ACCESS_TYPE_WHITELIST = "whitelist" + ACCESS_TYPE_BLACKLIST = "blacklist" + ACCESS_TYPE_NONE = "none" +) +``` + +#### func ExtractDest + +```go +func ExtractDest(input string) string +``` + +#### func ExtractPairInt + +```go +func ExtractPairInt(input, value string) int +``` + +#### func ExtractPairString + +```go +func ExtractPairString(input, value string) string +``` + +#### func IgnorePortError + +```go +func IgnorePortError(err error) error +``` + +#### func RandPort + +```go +func RandPort() (portNumber string, err error) +``` + +#### func SetAccessList + +```go +func SetAccessList(s []string) func(*SAMEmit) error +``` +SetAccessList tells the system to treat the AccessList as a whitelist + +#### func SetAccessListType + +```go +func SetAccessListType(s string) func(*SAMEmit) error +``` +SetAccessListType tells the system to treat the AccessList as a whitelist + +#### func SetAllowZeroIn + +```go +func SetAllowZeroIn(b bool) func(*SAMEmit) error +``` +SetAllowZeroIn tells the tunnel to accept zero-hop peers + +#### func SetAllowZeroOut + +```go +func SetAllowZeroOut(b bool) func(*SAMEmit) error +``` +SetAllowZeroOut tells the tunnel to accept zero-hop peers + +#### func SetCloseIdle + +```go +func SetCloseIdle(b bool) func(*SAMEmit) error +``` +SetCloseIdle tells the connection to close it's tunnels during extended idle +time. + +#### func SetCloseIdleTime + +```go +func SetCloseIdleTime(u int) func(*SAMEmit) error +``` +SetCloseIdleTime sets the time to wait before closing tunnels to idle levels + +#### func SetCloseIdleTimeMs + +```go +func SetCloseIdleTimeMs(u int) func(*SAMEmit) error +``` +SetCloseIdleTimeMs sets the time to wait before closing tunnels to idle levels +in milliseconds + +#### func SetCompress + +```go +func SetCompress(b bool) func(*SAMEmit) error +``` +SetCompress tells clients to use compression + +#### func SetEncrypt + +```go +func SetEncrypt(b bool) func(*SAMEmit) error +``` +SetEncrypt tells the router to use an encrypted leaseset + +#### func SetFastRecieve + +```go +func SetFastRecieve(b bool) func(*SAMEmit) error +``` +SetFastRecieve tells clients to use compression + +#### func SetInBackups + +```go +func SetInBackups(u int) func(*SAMEmit) error +``` +SetInBackups sets the inbound tunnel backups + +#### func SetInLength + +```go +func SetInLength(u int) func(*SAMEmit) error +``` +SetInLength sets the number of hops inbound + +#### func SetInQuantity + +```go +func SetInQuantity(u int) func(*SAMEmit) error +``` +SetInQuantity sets the inbound tunnel quantity + +#### func SetInVariance + +```go +func SetInVariance(i int) func(*SAMEmit) error +``` +SetInVariance sets the variance of a number of hops inbound + +#### func SetLeaseSetKey + +```go +func SetLeaseSetKey(s string) func(*SAMEmit) error +``` +SetLeaseSetKey sets the host of the SAMEmit's SAM bridge + +#### func SetLeaseSetPrivateKey + +```go +func SetLeaseSetPrivateKey(s string) func(*SAMEmit) error +``` +SetLeaseSetPrivateKey sets the host of the SAMEmit's SAM bridge + +#### func SetLeaseSetPrivateSigningKey + +```go +func SetLeaseSetPrivateSigningKey(s string) func(*SAMEmit) error +``` +SetLeaseSetPrivateSigningKey sets the host of the SAMEmit's SAM bridge + +#### func SetMessageReliability + +```go +func SetMessageReliability(s string) func(*SAMEmit) error +``` +SetMessageReliability sets the host of the SAMEmit's SAM bridge + +#### func SetName + +```go +func SetName(s string) func(*SAMEmit) error +``` +SetName sets the host of the SAMEmit's SAM bridge + +#### func SetOutBackups + +```go +func SetOutBackups(u int) func(*SAMEmit) error +``` +SetOutBackups sets the inbound tunnel backups + +#### func SetOutLength + +```go +func SetOutLength(u int) func(*SAMEmit) error +``` +SetOutLength sets the number of hops outbound + +#### func SetOutQuantity + +```go +func SetOutQuantity(u int) func(*SAMEmit) error +``` +SetOutQuantity sets the outbound tunnel quantity + +#### func SetOutVariance + +```go +func SetOutVariance(i int) func(*SAMEmit) error +``` +SetOutVariance sets the variance of a number of hops outbound + +#### func SetReduceIdle + +```go +func SetReduceIdle(b bool) func(*SAMEmit) error +``` +SetReduceIdle tells the connection to reduce it's tunnels during extended idle +time. + +#### func SetReduceIdleQuantity + +```go +func SetReduceIdleQuantity(u int) func(*SAMEmit) error +``` +SetReduceIdleQuantity sets minimum number of tunnels to reduce to during idle +time + +#### func SetReduceIdleTime + +```go +func SetReduceIdleTime(u int) func(*SAMEmit) error +``` +SetReduceIdleTime sets the time to wait before reducing tunnels to idle levels + +#### func SetReduceIdleTimeMs + +```go +func SetReduceIdleTimeMs(u int) func(*SAMEmit) error +``` +SetReduceIdleTimeMs sets the time to wait before reducing tunnels to idle levels +in milliseconds + +#### func SetSAMAddress + +```go +func SetSAMAddress(s string) func(*SAMEmit) error +``` +SetSAMAddress sets the SAM address all-at-once + +#### func SetSAMHost + +```go +func SetSAMHost(s string) func(*SAMEmit) error +``` +SetSAMHost sets the host of the SAMEmit's SAM bridge + +#### func SetSAMPort + +```go +func SetSAMPort(s string) func(*SAMEmit) error +``` +SetSAMPort sets the port of the SAMEmit's SAM bridge using a string + +#### func SetType + +```go +func SetType(s string) func(*SAMEmit) error +``` +SetType sets the type of the forwarder server + +#### func SplitHostPort + +```go +func SplitHostPort(hostport string) (string, string, error) +``` + +#### type BaseSession + +```go +type BaseSession struct { + SAM SAM +} +``` + + +#### func (*BaseSession) Close + +```go +func (bs *BaseSession) Close() error +``` + +#### func (*BaseSession) From + +```go +func (bs *BaseSession) From() string +``` + +#### func (*BaseSession) ID + +```go +func (bs *BaseSession) ID() string +``` + +#### func (*BaseSession) Keys + +```go +func (bs *BaseSession) Keys() i2pkeys.I2PKeys +``` + +#### func (*BaseSession) LocalAddr + +```go +func (bs *BaseSession) LocalAddr() net.Addr +``` + +#### func (*BaseSession) Read + +```go +func (bs *BaseSession) Read(b []byte) (int, error) +``` + +#### func (*BaseSession) RemoteAddr + +```go +func (bs *BaseSession) RemoteAddr() net.Addr +``` + +#### func (*BaseSession) SetDeadline + +```go +func (bs *BaseSession) SetDeadline(t time.Time) error +``` + +#### func (*BaseSession) SetReadDeadline + +```go +func (bs *BaseSession) SetReadDeadline(t time.Time) error +``` + +#### func (*BaseSession) SetWriteDeadline + +```go +func (bs *BaseSession) SetWriteDeadline(t time.Time) error +``` + +#### func (*BaseSession) To + +```go +func (bs *BaseSession) To() string +``` + +#### func (*BaseSession) Write + +```go +func (bs *BaseSession) Write(b []byte) (int, error) +``` + +#### type I2PConfig + +```go +type I2PConfig struct { + SamHost string + SamPort int + TunName string + + SamMin string + SamMax string + + Fromport string + Toport string + + Style string + TunType string + + DestinationKeys *i2pkeys.I2PKeys + + SigType string + EncryptLeaseSet bool + LeaseSetKey string + LeaseSetPrivateKey string + LeaseSetPrivateSigningKey string + LeaseSetKeys i2pkeys.I2PKeys + InAllowZeroHop bool + OutAllowZeroHop bool + InLength int + OutLength int + InQuantity int + OutQuantity int + InVariance int + OutVariance int + InBackupQuantity int + OutBackupQuantity int + FastRecieve bool + UseCompression bool + MessageReliability string + CloseIdle bool + CloseIdleTime int + ReduceIdle bool + ReduceIdleTime int + ReduceIdleQuantity int + LeaseSetEncryption string + + // Streaming Library options + AccessListType string + AccessList []string +} +``` + +I2PConfig is a struct which manages I2P configuration options. + +#### func NewConfig + +```go +func NewConfig(opts ...func(*I2PConfig) error) (*I2PConfig, error) +``` + +#### func (*I2PConfig) Accesslist + +```go +func (f *I2PConfig) Accesslist() string +``` +Accesslist generates the I2CP access list configuration string based on the +configured access list + +#### func (*I2PConfig) Accesslisttype + +```go +func (f *I2PConfig) Accesslisttype() string +``` +Accesslisttype returns the I2CP access list configuration string based on the +AccessListType setting + +#### func (*I2PConfig) Close + +```go +func (f *I2PConfig) Close() string +``` +Close returns I2CP close-on-idle configuration settings as a string if enabled + +#### func (*I2PConfig) DestinationKey + +```go +func (f *I2PConfig) DestinationKey() string +``` +DestinationKey returns the DESTINATION configuration string for the SAM bridge +If destination keys are set, returns them as a string, otherwise returns +"TRANSIENT" + +#### func (*I2PConfig) DoZero + +```go +func (f *I2PConfig) DoZero() string +``` +DoZero returns the zero hop and fast receive configuration string settings + +#### func (*I2PConfig) EncryptLease + +```go +func (f *I2PConfig) EncryptLease() string +``` +EncryptLease returns the lease set encryption configuration string Returns +"i2cp.encryptLeaseSet=true" if encryption is enabled, empty string otherwise + +#### func (*I2PConfig) FromPort + +```go +func (f *I2PConfig) FromPort() string +``` +FromPort returns the FROM_PORT configuration string for SAM bridges >= 3.1 +Returns an empty string if SAM version < 3.1 or if fromport is "0" + +#### func (*I2PConfig) ID + +```go +func (f *I2PConfig) ID() string +``` +ID returns the tunnel name as a formatted string. If no tunnel name is set, +generates a random 12-character name using lowercase letters. + +#### func (*I2PConfig) InboundBackupQuantity + +```go +func (f *I2PConfig) InboundBackupQuantity() string +``` + +#### func (*I2PConfig) InboundLength + +```go +func (f *I2PConfig) InboundLength() string +``` + +#### func (*I2PConfig) InboundLengthVariance + +```go +func (f *I2PConfig) InboundLengthVariance() string +``` + +#### func (*I2PConfig) InboundQuantity + +```go +func (f *I2PConfig) InboundQuantity() string +``` + +#### func (*I2PConfig) LeaseSetEncryptionType + +```go +func (f *I2PConfig) LeaseSetEncryptionType() string +``` +LeaseSetEncryptionType returns the I2CP lease set encryption type configuration +string. If no encryption type is set, returns default value "4,0". Validates +that all encryption types are valid integers. + +#### func (*I2PConfig) LeaseSetSettings + +```go +func (f *I2PConfig) LeaseSetSettings() (string, string, string) +``` +Leasesetsettings returns the lease set configuration strings for I2P Returns +three strings: lease set key, private key, and private signing key settings + +#### func (*I2PConfig) MaxSAM + +```go +func (f *I2PConfig) MaxSAM() string +``` +MaxSAM returns the maximum SAM version supported as a string If no maximum +version is set, returns default value "3.1" + +#### func (*I2PConfig) MinSAM + +```go +func (f *I2PConfig) MinSAM() string +``` +MinSAM returns the minimum SAM version supported as a string If no minimum +version is set, returns default value "3.0" + +#### func (*I2PConfig) OutboundBackupQuantity + +```go +func (f *I2PConfig) OutboundBackupQuantity() string +``` + +#### func (*I2PConfig) OutboundLength + +```go +func (f *I2PConfig) OutboundLength() string +``` + +#### func (*I2PConfig) OutboundLengthVariance + +```go +func (f *I2PConfig) OutboundLengthVariance() string +``` + +#### func (*I2PConfig) OutboundQuantity + +```go +func (f *I2PConfig) OutboundQuantity() string +``` + +#### func (*I2PConfig) Print + +```go +func (f *I2PConfig) Print() []string +``` +Print returns a slice of strings containing all the I2P configuration settings + +#### func (*I2PConfig) Reduce + +```go +func (f *I2PConfig) Reduce() string +``` +Reduce returns I2CP reduce-on-idle configuration settings as a string if enabled + +#### func (*I2PConfig) Reliability + +```go +func (f *I2PConfig) Reliability() string +``` +Reliability returns the message reliability configuration string for the SAM +bridge If a reliability setting is specified, returns formatted +i2cp.messageReliability setting + +#### func (*I2PConfig) SAMAddress + +```go +func (f *I2PConfig) SAMAddress() string +``` +SAMAddress returns the SAM bridge address in the format "host:port" This is a +convenience method that uses the Sam() function to get the address. It is used +to provide a consistent interface for retrieving the SAM address. + +#### func (*I2PConfig) Sam + +```go +func (f *I2PConfig) Sam() string +``` +Sam returns the SAM bridge address as a string in the format "host:port" + +#### func (*I2PConfig) SessionStyle + +```go +func (f *I2PConfig) SessionStyle() string +``` +SessionStyle returns the SAM session style configuration string If no style is +set, defaults to "STREAM" + +#### func (*I2PConfig) SetSAMAddress + +```go +func (f *I2PConfig) SetSAMAddress(addr string) +``` +SetSAMAddress sets the SAM bridge host and port from a combined address string. +If no address is provided, it sets default values for the host and port. + +#### func (*I2PConfig) SignatureType + +```go +func (f *I2PConfig) SignatureType() string +``` +SignatureType returns the SIGNATURE_TYPE configuration string for SAM bridges >= +3.1 Returns empty string if SAM version < 3.1 or if no signature type is set + +#### func (*I2PConfig) ToPort + +```go +func (f *I2PConfig) ToPort() string +``` +ToPort returns the TO_PORT configuration string for SAM bridges >= 3.1 Returns +an empty string if SAM version < 3.1 or if toport is "0" + +#### func (*I2PConfig) UsingCompression + +```go +func (f *I2PConfig) UsingCompression() string +``` + +#### type Option + +```go +type Option func(*SAMEmit) error +``` + +Option is a SAMEmit Option + +#### type Options + +```go +type Options map[string]string +``` + +options map + +#### func (Options) AsList + +```go +func (opts Options) AsList() (ls []string) +``` +obtain sam options as list of strings + +#### type SAM + +```go +type SAM struct { + SAMEmit + SAMResolver + net.Conn + + // Timeout for SAM connections + Timeout time.Duration + // Context for control of lifecycle + Context context.Context +} +``` + +Used for controlling I2Ps SAMv3. + +#### func NewSAM + +```go +func NewSAM(address string) (*SAM, error) +``` +NewSAM creates a new SAM instance by connecting to the specified address, +performing the hello handshake, and initializing the SAM resolver. It returns a +pointer to the SAM instance or an error if any step fails. This function +combines connection establishment and hello handshake into a single step, +eliminating the need for separate helper functions. It also initializes the SAM +resolver directly after the connection is established. The SAM instance is ready +to use for further operations like session creation or name resolution. + +#### func (*SAM) Close + +```go +func (sam *SAM) Close() error +``` +close this sam session + +#### func (*SAM) EnsureKeyfile + +```go +func (sam *SAM) EnsureKeyfile(fname string) (keys i2pkeys.I2PKeys, err error) +``` +if keyfile fname does not exist + +#### func (*SAM) Keys + +```go +func (sam *SAM) Keys() (k *i2pkeys.I2PKeys) +``` + +#### func (*SAM) Lookup + +```go +func (sam *SAM) Lookup(name string) (i2pkeys.I2PAddr, error) +``` +Performs a lookup, probably this order: 1) routers known addresses, cached +addresses, 3) by asking peers in the I2P network. + +#### func (SAM) NewGenericSession + +```go +func (sam SAM) NewGenericSession(style, id string, keys i2pkeys.I2PKeys, extras []string) (Session, error) +``` +Creates a new session with the style of either "STREAM", "DATAGRAM" or "RAW", +for a new I2P tunnel with name id, using the cypher keys specified, with the +I2CP/streaminglib-options as specified. Extra arguments can be specified by +setting extra to something else than []string{}. This sam3 instance is now a +session + +#### func (SAM) NewGenericSessionWithSignature + +```go +func (sam SAM) NewGenericSessionWithSignature(style, id string, keys i2pkeys.I2PKeys, sigType string, extras []string) (Session, error) +``` + +#### func (SAM) NewGenericSessionWithSignatureAndPorts + +```go +func (sam SAM) NewGenericSessionWithSignatureAndPorts(style, id, from, to string, keys i2pkeys.I2PKeys, sigType string, extras []string) (Session, error) +``` +Creates a new session with the style of either "STREAM", "DATAGRAM" or "RAW", +for a new I2P tunnel with name id, using the cypher keys specified, with the +I2CP/streaminglib-options as specified. Extra arguments can be specified by +setting extra to something else than []string{}. This sam3 instance is now a +session + +#### func (*SAM) NewKeys + +```go +func (sam *SAM) NewKeys(sigType ...string) (i2pkeys.I2PKeys, error) +``` +Creates the I2P-equivalent of an IP address, that is unique and only the one who +has the private keys can send messages from. The public keys are the I2P +desination (the address) that anyone can send messages to. + +#### func (*SAM) ReadKeys + +```go +func (sam *SAM) ReadKeys(r io.Reader) (err error) +``` +read public/private keys from an io.Reader + +#### type SAMEmit + +```go +type SAMEmit struct { + I2PConfig +} +``` + + +#### func NewEmit + +```go +func NewEmit(opts ...func(*SAMEmit) error) (*SAMEmit, error) +``` + +#### func (*SAMEmit) Accept + +```go +func (e *SAMEmit) Accept() string +``` + +#### func (*SAMEmit) AcceptBytes + +```go +func (e *SAMEmit) AcceptBytes() []byte +``` + +#### func (*SAMEmit) Connect + +```go +func (e *SAMEmit) Connect(dest string) string +``` + +#### func (*SAMEmit) ConnectBytes + +```go +func (e *SAMEmit) ConnectBytes(dest string) []byte +``` + +#### func (*SAMEmit) Create + +```go +func (e *SAMEmit) Create() string +``` + +#### func (*SAMEmit) CreateBytes + +```go +func (e *SAMEmit) CreateBytes() []byte +``` + +#### func (*SAMEmit) GenerateDestination + +```go +func (e *SAMEmit) GenerateDestination() string +``` + +#### func (*SAMEmit) GenerateDestinationBytes + +```go +func (e *SAMEmit) GenerateDestinationBytes() []byte +``` + +#### func (*SAMEmit) Hello + +```go +func (e *SAMEmit) Hello() string +``` + +#### func (*SAMEmit) HelloBytes + +```go +func (e *SAMEmit) HelloBytes() []byte +``` + +#### func (*SAMEmit) Lookup + +```go +func (e *SAMEmit) Lookup(name string) string +``` + +#### func (*SAMEmit) LookupBytes + +```go +func (e *SAMEmit) LookupBytes(name string) []byte +``` + +#### func (*SAMEmit) SamOptionsString + +```go +func (e *SAMEmit) SamOptionsString() string +``` + +#### type SAMResolver + +```go +type SAMResolver struct { + *SAM +} +``` + + +#### func NewFullSAMResolver + +```go +func NewFullSAMResolver(address string) (*SAMResolver, error) +``` + +#### func NewSAMResolver + +```go +func NewSAMResolver(parent *SAM) (*SAMResolver, error) +``` + +#### func (*SAMResolver) Resolve + +```go +func (sam *SAMResolver) Resolve(name string) (i2pkeys.I2PAddr, error) +``` +Performs a lookup, probably this order: 1) routers known addresses, cached +addresses, 3) by asking peers in the I2P network. + +#### type Session + +```go +type Session interface { + net.Conn + ID() string + Keys() i2pkeys.I2PKeys + Close() error +} +``` diff --git a/datagram/DOC.md b/datagram/DOC.md new file mode 100644 index 0000000..e27b63b --- /dev/null +++ b/datagram/DOC.md @@ -0,0 +1,353 @@ +# datagram +-- + import "github.com/go-i2p/go-sam-go/datagram" + + +## Usage + +#### type Datagram + +```go +type Datagram struct { + Data []byte + Source i2pkeys.I2PAddr + Local i2pkeys.I2PAddr +} +``` + +Datagram represents an I2P datagram message + +#### type DatagramAddr + +```go +type DatagramAddr struct { +} +``` + +DatagramAddr implements net.Addr for I2P datagram addresses + +#### func (*DatagramAddr) Network + +```go +func (a *DatagramAddr) Network() string +``` +Network returns the network type + +#### func (*DatagramAddr) String + +```go +func (a *DatagramAddr) String() string +``` +String returns the string representation of the address + +#### type DatagramConn + +```go +type DatagramConn struct { +} +``` + +DatagramConn implements net.PacketConn for I2P datagrams + +#### func (*DatagramConn) Close + +```go +func (c *DatagramConn) Close() error +``` +Close closes the datagram connection + +#### func (*DatagramConn) LocalAddr + +```go +func (c *DatagramConn) LocalAddr() net.Addr +``` +LocalAddr returns the local address + +#### func (*DatagramConn) Read + +```go +func (c *DatagramConn) Read(b []byte) (n int, err error) +``` +Read implements net.Conn by wrapping ReadFrom. It reads data into the provided +byte slice and returns the number of bytes read. When reading, it also updates +the remote address of the connection. Note: This is not a typical use case for +datagrams, as they are connectionless. However, for compatibility with net.Conn, +we implement it this way. + +#### func (*DatagramConn) ReadFrom + +```go +func (c *DatagramConn) ReadFrom(p []byte) (n int, addr net.Addr, err error) +``` +ReadFrom reads a datagram from the connection + +#### func (*DatagramConn) RemoteAddr + +```go +func (c *DatagramConn) RemoteAddr() net.Addr +``` +RemoteAddr returns the remote address of the connection. For datagram +connections, this returns nil as there is no single remote address. + +#### func (*DatagramConn) SetDeadline + +```go +func (c *DatagramConn) SetDeadline(t time.Time) error +``` +SetDeadline sets the read and write deadlines + +#### func (*DatagramConn) SetReadDeadline + +```go +func (c *DatagramConn) SetReadDeadline(t time.Time) error +``` +SetReadDeadline sets the deadline for future ReadFrom calls + +#### func (*DatagramConn) SetWriteDeadline + +```go +func (c *DatagramConn) SetWriteDeadline(t time.Time) error +``` +SetWriteDeadline sets the deadline for future WriteTo calls + +#### func (*DatagramConn) Write + +```go +func (c *DatagramConn) Write(b []byte) (n int, err error) +``` +Write implements net.Conn by wrapping WriteTo. It writes data to the remote +address and returns the number of bytes written. It uses the remote address set +by the last Read operation. If no remote address is set, it returns an error. +Note: This is not a typical use case for datagrams, as they are connectionless. +However, for compatibility with net.Conn, we implement it this way. + +#### func (*DatagramConn) WriteTo + +```go +func (c *DatagramConn) WriteTo(p []byte, addr net.Addr) (n int, err error) +``` +WriteTo writes a datagram to the specified address + +#### type DatagramListener + +```go +type DatagramListener struct { +} +``` + +DatagramListener implements net.DatagramListener for I2P datagram connections + +#### func (*DatagramListener) Accept + +```go +func (l *DatagramListener) Accept() (net.Conn, error) +``` +Accept waits for and returns the next packet connection to the listener + +#### func (*DatagramListener) Addr + +```go +func (l *DatagramListener) Addr() net.Addr +``` +Addr returns the listener's network address + +#### func (*DatagramListener) Close + +```go +func (l *DatagramListener) Close() error +``` +Close closes the packet listener + +#### type DatagramReader + +```go +type DatagramReader struct { +} +``` + +DatagramReader handles incoming datagram reception + +#### func (*DatagramReader) Close + +```go +func (r *DatagramReader) Close() error +``` + +#### func (*DatagramReader) ReceiveDatagram + +```go +func (r *DatagramReader) ReceiveDatagram() (*Datagram, error) +``` +ReceiveDatagram receives a datagram from any source + +#### type DatagramSession + +```go +type DatagramSession struct { + *common.BaseSession +} +``` + +DatagramSession represents a datagram session that can send and receive +datagrams + +#### func NewDatagramSession + +```go +func NewDatagramSession(sam *common.SAM, id string, keys i2pkeys.I2PKeys, options []string) (*DatagramSession, error) +``` +NewDatagramSession creates a new datagram session + +#### func (*DatagramSession) Addr + +```go +func (s *DatagramSession) Addr() i2pkeys.I2PAddr +``` +Addr returns the I2P address of this session + +#### func (*DatagramSession) Close + +```go +func (s *DatagramSession) Close() error +``` +Close closes the datagram session and all associated resources + +#### func (*DatagramSession) Dial + +```go +func (ds *DatagramSession) Dial(destination string) (net.PacketConn, error) +``` +Dial establishes a datagram connection to the specified destination + +#### func (*DatagramSession) DialContext + +```go +func (ds *DatagramSession) DialContext(ctx context.Context, destination string) (net.PacketConn, error) +``` +DialContext establishes a datagram connection with context support + +#### func (*DatagramSession) DialI2P + +```go +func (ds *DatagramSession) DialI2P(addr i2pkeys.I2PAddr) (net.PacketConn, error) +``` +DialI2P establishes a datagram connection to an I2P address + +#### func (*DatagramSession) DialI2PContext + +```go +func (ds *DatagramSession) DialI2PContext(ctx context.Context, addr i2pkeys.I2PAddr) (net.PacketConn, error) +``` +DialI2PContext establishes a datagram connection to an I2P address with context +support + +#### func (*DatagramSession) DialI2PTimeout + +```go +func (ds *DatagramSession) DialI2PTimeout(addr i2pkeys.I2PAddr, timeout time.Duration) (net.PacketConn, error) +``` +DialI2PTimeout establishes a datagram connection to an I2P address with timeout + +#### func (*DatagramSession) DialTimeout + +```go +func (ds *DatagramSession) DialTimeout(destination string, timeout time.Duration) (net.PacketConn, error) +``` +DialTimeout establishes a datagram connection with a timeout + +#### func (*DatagramSession) Listen + +```go +func (s *DatagramSession) Listen() (*DatagramListener, error) +``` + +#### func (*DatagramSession) NewReader + +```go +func (s *DatagramSession) NewReader() *DatagramReader +``` +NewReader creates a DatagramReader for receiving datagrams + +#### func (*DatagramSession) NewWriter + +```go +func (s *DatagramSession) NewWriter() *DatagramWriter +``` +NewWriter creates a DatagramWriter for sending datagrams + +#### func (*DatagramSession) PacketConn + +```go +func (s *DatagramSession) PacketConn() net.PacketConn +``` +PacketConn returns a net.PacketConn interface for this session + +#### func (*DatagramSession) ReceiveDatagram + +```go +func (s *DatagramSession) ReceiveDatagram() (*Datagram, error) +``` +ReceiveDatagram receives a datagram from any source + +#### func (*DatagramSession) SendDatagram + +```go +func (s *DatagramSession) SendDatagram(data []byte, dest i2pkeys.I2PAddr) error +``` +SendDatagram sends a datagram to the specified destination + +#### type DatagramWriter + +```go +type DatagramWriter struct { +} +``` + +DatagramWriter handles outgoing datagram transmission + +#### func (*DatagramWriter) SendDatagram + +```go +func (w *DatagramWriter) SendDatagram(data []byte, dest i2pkeys.I2PAddr) error +``` +SendDatagram sends a datagram to the specified destination + +#### func (*DatagramWriter) SetTimeout + +```go +func (w *DatagramWriter) SetTimeout(timeout time.Duration) *DatagramWriter +``` +SetTimeout sets the timeout for datagram operations + +#### type SAM + +```go +type SAM struct { + *common.SAM +} +``` + +SAM wraps common.SAM to provide datagram-specific functionality + +#### func (*SAM) NewDatagramSession + +```go +func (s *SAM) NewDatagramSession(id string, keys i2pkeys.I2PKeys, options []string) (*DatagramSession, error) +``` +NewDatagramSession creates a new datagram session with the SAM bridge + +#### func (*SAM) NewDatagramSessionWithPorts + +```go +func (s *SAM) NewDatagramSessionWithPorts(id, fromPort, toPort string, keys i2pkeys.I2PKeys, options []string) (*DatagramSession, error) +``` +NewDatagramSessionWithPorts creates a new datagram session with port +specifications + +#### func (*SAM) NewDatagramSessionWithSignature + +```go +func (s *SAM) NewDatagramSessionWithSignature(id string, keys i2pkeys.I2PKeys, options []string, sigType string) (*DatagramSession, error) +``` +NewDatagramSessionWithSignature creates a new datagram session with custom +signature type diff --git a/primary/DOC.md b/primary/DOC.md new file mode 100644 index 0000000..443f476 --- /dev/null +++ b/primary/DOC.md @@ -0,0 +1,6 @@ +# primary +-- + import "github.com/go-i2p/go-sam-go/primary" + + +## Usage diff --git a/raw/DOC.md b/raw/DOC.md new file mode 100644 index 0000000..78c625a --- /dev/null +++ b/raw/DOC.md @@ -0,0 +1,341 @@ +# raw +-- + import "github.com/go-i2p/go-sam-go/raw" + + +## Usage + +#### type RawAddr + +```go +type RawAddr struct { +} +``` + +RawAddr implements net.Addr for I2P raw addresses + +#### func (*RawAddr) Network + +```go +func (a *RawAddr) Network() string +``` +Network returns the network type + +#### func (*RawAddr) String + +```go +func (a *RawAddr) String() string +``` +String returns the string representation of the address + +#### type RawConn + +```go +type RawConn struct { +} +``` + +RawConn implements net.PacketConn for I2P raw datagrams + +#### func (*RawConn) Close + +```go +func (c *RawConn) Close() error +``` +Close closes the raw connection + +#### func (*RawConn) LocalAddr + +```go +func (c *RawConn) LocalAddr() net.Addr +``` +LocalAddr returns the local address + +#### func (*RawConn) Read + +```go +func (c *RawConn) Read(b []byte) (n int, err error) +``` +Read implements net.Conn by wrapping ReadFrom + +#### func (*RawConn) ReadFrom + +```go +func (c *RawConn) ReadFrom(p []byte) (n int, addr net.Addr, err error) +``` +ReadFrom reads a raw datagram from the connection + +#### func (*RawConn) RemoteAddr + +```go +func (c *RawConn) RemoteAddr() net.Addr +``` +RemoteAddr returns the remote address of the connection + +#### func (*RawConn) SetDeadline + +```go +func (c *RawConn) SetDeadline(t time.Time) error +``` +SetDeadline sets the read and write deadlines + +#### func (*RawConn) SetReadDeadline + +```go +func (c *RawConn) SetReadDeadline(t time.Time) error +``` +SetReadDeadline sets the deadline for future ReadFrom calls + +#### func (*RawConn) SetWriteDeadline + +```go +func (c *RawConn) SetWriteDeadline(t time.Time) error +``` +SetWriteDeadline sets the deadline for future WriteTo calls + +#### func (*RawConn) Write + +```go +func (c *RawConn) Write(b []byte) (n int, err error) +``` +Write implements net.Conn by wrapping WriteTo + +#### func (*RawConn) WriteTo + +```go +func (c *RawConn) WriteTo(p []byte, addr net.Addr) (n int, err error) +``` +WriteTo writes a raw datagram to the specified address + +#### type RawDatagram + +```go +type RawDatagram struct { + Data []byte + Source i2pkeys.I2PAddr + Local i2pkeys.I2PAddr +} +``` + +RawDatagram represents an I2P raw datagram message + +#### type RawListener + +```go +type RawListener struct { +} +``` + +RawListener implements net.Listener for I2P raw connections + +#### func (*RawListener) Accept + +```go +func (l *RawListener) Accept() (net.Conn, error) +``` +Accept waits for and returns the next raw connection to the listener + +#### func (*RawListener) Addr + +```go +func (l *RawListener) Addr() net.Addr +``` +Addr returns the listener's network address + +#### func (*RawListener) Close + +```go +func (l *RawListener) Close() error +``` +Close closes the raw listener + +#### type RawReader + +```go +type RawReader struct { +} +``` + +RawReader handles incoming raw datagram reception + +#### func (*RawReader) Close + +```go +func (r *RawReader) Close() error +``` + +#### func (*RawReader) ReceiveDatagram + +```go +func (r *RawReader) ReceiveDatagram() (*RawDatagram, error) +``` +ReceiveDatagram receives a raw datagram from any source + +#### type RawSession + +```go +type RawSession struct { + *common.BaseSession +} +``` + +RawSession represents a raw session that can send and receive raw datagrams + +#### func NewRawSession + +```go +func NewRawSession(sam *common.SAM, id string, keys i2pkeys.I2PKeys, options []string) (*RawSession, error) +``` +NewRawSession creates a new raw session + +#### func (*RawSession) Addr + +```go +func (s *RawSession) Addr() i2pkeys.I2PAddr +``` +Addr returns the I2P address of this session + +#### func (*RawSession) Close + +```go +func (s *RawSession) Close() error +``` +Close closes the raw session and all associated resources + +#### func (*RawSession) Dial + +```go +func (rs *RawSession) Dial(destination string) (net.PacketConn, error) +``` +Dial establishes a raw connection to the specified destination + +#### func (*RawSession) DialContext + +```go +func (rs *RawSession) DialContext(ctx context.Context, destination string) (net.PacketConn, error) +``` +DialContext establishes a raw connection with context support + +#### func (*RawSession) DialI2P + +```go +func (rs *RawSession) DialI2P(addr i2pkeys.I2PAddr) (net.PacketConn, error) +``` +DialI2P establishes a raw connection to an I2P address + +#### func (*RawSession) DialI2PContext + +```go +func (rs *RawSession) DialI2PContext(ctx context.Context, addr i2pkeys.I2PAddr) (net.PacketConn, error) +``` +DialI2PContext establishes a raw connection to an I2P address with context +support + +#### func (*RawSession) DialI2PTimeout + +```go +func (rs *RawSession) DialI2PTimeout(addr i2pkeys.I2PAddr, timeout time.Duration) (net.PacketConn, error) +``` +DialI2PTimeout establishes a raw connection to an I2P address with timeout + +#### func (*RawSession) DialTimeout + +```go +func (rs *RawSession) DialTimeout(destination string, timeout time.Duration) (net.PacketConn, error) +``` +DialTimeout establishes a raw connection with a timeout + +#### func (*RawSession) Listen + +```go +func (s *RawSession) Listen() (*RawListener, error) +``` + +#### func (*RawSession) NewReader + +```go +func (s *RawSession) NewReader() *RawReader +``` +NewReader creates a RawReader for receiving raw datagrams + +#### func (*RawSession) NewWriter + +```go +func (s *RawSession) NewWriter() *RawWriter +``` +NewWriter creates a RawWriter for sending raw datagrams + +#### func (*RawSession) PacketConn + +```go +func (s *RawSession) PacketConn() net.PacketConn +``` +PacketConn returns a net.PacketConn interface for this session + +#### func (*RawSession) ReceiveDatagram + +```go +func (s *RawSession) ReceiveDatagram() (*RawDatagram, error) +``` +ReceiveDatagram receives a raw datagram from any source + +#### func (*RawSession) SendDatagram + +```go +func (s *RawSession) SendDatagram(data []byte, dest i2pkeys.I2PAddr) error +``` +SendDatagram sends a raw datagram to the specified destination + +#### type RawWriter + +```go +type RawWriter struct { +} +``` + +RawWriter handles outgoing raw datagram transmission + +#### func (*RawWriter) SendDatagram + +```go +func (w *RawWriter) SendDatagram(data []byte, dest i2pkeys.I2PAddr) error +``` +SendDatagram sends a raw datagram to the specified destination + +#### func (*RawWriter) SetTimeout + +```go +func (w *RawWriter) SetTimeout(timeout time.Duration) *RawWriter +``` +SetTimeout sets the timeout for raw datagram operations + +#### type SAM + +```go +type SAM struct { + *common.SAM +} +``` + +SAM wraps common.SAM to provide raw-specific functionality + +#### func (*SAM) NewRawSession + +```go +func (s *SAM) NewRawSession(id string, keys i2pkeys.I2PKeys, options []string) (*RawSession, error) +``` +NewRawSession creates a new raw session with the SAM bridge + +#### func (*SAM) NewRawSessionWithPorts + +```go +func (s *SAM) NewRawSessionWithPorts(id, fromPort, toPort string, keys i2pkeys.I2PKeys, options []string) (*RawSession, error) +``` +NewRawSessionWithPorts creates a new raw session with port specifications + +#### func (*SAM) NewRawSessionWithSignature + +```go +func (s *SAM) NewRawSessionWithSignature(id string, keys i2pkeys.I2PKeys, options []string, sigType string) (*RawSession, error) +``` +NewRawSessionWithSignature creates a new raw session with custom signature type diff --git a/stream/DOC.md b/stream/DOC.md new file mode 100644 index 0000000..e1bfa01 --- /dev/null +++ b/stream/DOC.md @@ -0,0 +1,252 @@ +# stream +-- + import "github.com/go-i2p/go-sam-go/stream" + + +## Usage + +#### type SAM + +```go +type SAM struct { + *common.SAM +} +``` + +SAM wraps common.SAM to provide stream-specific functionality + +#### func (*SAM) NewStreamSession + +```go +func (s *SAM) NewStreamSession(id string, keys i2pkeys.I2PKeys, options []string) (*StreamSession, error) +``` +NewStreamSession creates a new streaming session with the SAM bridge + +#### func (*SAM) NewStreamSessionWithPorts + +```go +func (s *SAM) NewStreamSessionWithPorts(id, fromPort, toPort string, keys i2pkeys.I2PKeys, options []string) (*StreamSession, error) +``` +NewStreamSessionWithPorts creates a new streaming session with port +specifications + +#### func (*SAM) NewStreamSessionWithSignature + +```go +func (s *SAM) NewStreamSessionWithSignature(id string, keys i2pkeys.I2PKeys, options []string, sigType string) (*StreamSession, error) +``` +NewStreamSessionWithSignature creates a new streaming session with custom +signature type + +#### type StreamConn + +```go +type StreamConn struct { +} +``` + +StreamConn implements net.Conn for I2P streaming connections + +#### func (*StreamConn) Close + +```go +func (c *StreamConn) Close() error +``` +Close closes the connection + +#### func (*StreamConn) LocalAddr + +```go +func (c *StreamConn) LocalAddr() net.Addr +``` +LocalAddr returns the local network address + +#### func (*StreamConn) Read + +```go +func (c *StreamConn) Read(b []byte) (int, error) +``` +Read reads data from the connection + +#### func (*StreamConn) RemoteAddr + +```go +func (c *StreamConn) RemoteAddr() net.Addr +``` +RemoteAddr returns the remote network address + +#### func (*StreamConn) SetDeadline + +```go +func (c *StreamConn) SetDeadline(t time.Time) error +``` +SetDeadline sets the read and write deadlines + +#### func (*StreamConn) SetReadDeadline + +```go +func (c *StreamConn) SetReadDeadline(t time.Time) error +``` +SetReadDeadline sets the deadline for future Read calls + +#### func (*StreamConn) SetWriteDeadline + +```go +func (c *StreamConn) SetWriteDeadline(t time.Time) error +``` +SetWriteDeadline sets the deadline for future Write calls + +#### func (*StreamConn) Write + +```go +func (c *StreamConn) Write(b []byte) (int, error) +``` +Write writes data to the connection + +#### type StreamDialer + +```go +type StreamDialer struct { +} +``` + +StreamDialer handles client-side connection establishment + +#### func (*StreamDialer) Dial + +```go +func (d *StreamDialer) Dial(destination string) (*StreamConn, error) +``` +Dial establishes a connection to the specified destination + +#### func (*StreamDialer) DialContext + +```go +func (d *StreamDialer) DialContext(ctx context.Context, destination string) (*StreamConn, error) +``` +DialContext establishes a connection with context support + +#### func (*StreamDialer) DialI2P + +```go +func (d *StreamDialer) DialI2P(addr i2pkeys.I2PAddr) (*StreamConn, error) +``` +DialI2P establishes a connection to the specified I2P address + +#### func (*StreamDialer) DialI2PContext + +```go +func (d *StreamDialer) DialI2PContext(ctx context.Context, addr i2pkeys.I2PAddr) (*StreamConn, error) +``` +DialI2PContext establishes a connection to an I2P address with context support + +#### func (*StreamDialer) SetTimeout + +```go +func (d *StreamDialer) SetTimeout(timeout time.Duration) *StreamDialer +``` +SetTimeout sets the default timeout for new dialers + +#### type StreamListener + +```go +type StreamListener struct { +} +``` + +StreamListener implements net.Listener for I2P streaming connections + +#### func (*StreamListener) Accept + +```go +func (l *StreamListener) Accept() (net.Conn, error) +``` +Accept waits for and returns the next connection to the listener + +#### func (*StreamListener) AcceptStream + +```go +func (l *StreamListener) AcceptStream() (*StreamConn, error) +``` +AcceptStream waits for and returns the next I2P streaming connection + +#### func (*StreamListener) Addr + +```go +func (l *StreamListener) Addr() net.Addr +``` +Addr returns the listener's network address + +#### func (*StreamListener) Close + +```go +func (l *StreamListener) Close() error +``` +Close closes the listener + +#### type StreamSession + +```go +type StreamSession struct { + *common.BaseSession +} +``` + +StreamSession represents a streaming session that can create listeners and +dialers + +#### func NewStreamSession + +```go +func NewStreamSession(sam *common.SAM, id string, keys i2pkeys.I2PKeys, options []string) (*StreamSession, error) +``` +NewStreamSession creates a new streaming session + +#### func (*StreamSession) Addr + +```go +func (s *StreamSession) Addr() i2pkeys.I2PAddr +``` +Addr returns the I2P address of this session + +#### func (*StreamSession) Close + +```go +func (s *StreamSession) Close() error +``` +Close closes the streaming session and all associated resources + +#### func (*StreamSession) Dial + +```go +func (s *StreamSession) Dial(destination string) (*StreamConn, error) +``` +Dial establishes a connection to the specified I2P destination + +#### func (*StreamSession) DialContext + +```go +func (s *StreamSession) DialContext(ctx context.Context, destination string) (*StreamConn, error) +``` +DialContext establishes a connection with context support + +#### func (*StreamSession) DialI2P + +```go +func (s *StreamSession) DialI2P(addr i2pkeys.I2PAddr) (*StreamConn, error) +``` +DialI2P establishes a connection to the specified I2P address + +#### func (*StreamSession) Listen + +```go +func (s *StreamSession) Listen() (*StreamListener, error) +``` +Listen creates a StreamListener that accepts incoming connections + +#### func (*StreamSession) NewDialer + +```go +func (s *StreamSession) NewDialer() *StreamDialer +``` +NewDialer creates a StreamDialer for establishing outbound connections