Documentation
¶
Index ¶
- Constants
- 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 SetDebug(b bool) func(*Client) error
- func SetEncrypt(b bool) 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 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 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 SetUnpublished(b bool) func(*Client) error
- type Client
- func (c *Client) Accept() (net.Conn, error)
- func (c *Client) Close() error
- func (c *Client) CreateStreamSession(dest string) (int32, string, error)
- func (c *Client) Dial(network, addr string) (net.Conn, error)
- func (c *Client) Lookup(name string) (string, error)
- func (c *Client) StreamAccept(id int32) (*Reply, error)
- func (c *Client) StreamConnect(id int32, dest string) error
- type Option
- type Reply
- type ReplyError
Examples ¶
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 ¶
This section is empty.
Functions ¶
func SetAddrMixed ¶
SetAddrMixed sets a clients's address in the form host, port(int)
func SetCloseIdle ¶
SetCloseIdle tells the router to use an encrypted leaseset
func SetCloseIdleTime ¶
SetCloseIdleTime sets the inbound tunnel backups
func SetEncrypt ¶
SetEncrypt tells the router to use an encrypted leaseset
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 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 SetPortInt ¶
SetPortInt sets the port of the client's SAM bridge using a string
func SetReduceIdle ¶
SetReduceIdle tells the router to use an encrypted leaseset
func SetReduceIdleQuantity ¶
SetReduceIdleQuantity sets the inbound tunnel backups
func SetReduceIdleTime ¶
SetReduceIdleTime sets the inbound tunnel backups
func SetUnpublished ¶
SetUnpublished tells the router to not publish the client leaseset
Types ¶
type Client ¶
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) CreateStreamSession ¶
CreateStreamSession creates a new STREAM Session. Returns the Id for the new Client.
func (*Client) Lookup ¶
Lookup askes SAM for the internal i2p address from name
Example ¶
client, err := NewDefaultClient()
if err != nil {
fmt.Printf("NewDefaultClient() should not throw an error.\n%s\n", err)
return
}
addr, err := client.Lookup("zzz.i2p")
if err != nil {
fmt.Printf("client.Lookup() should not throw an error.\n%s\n", err)
return
}
fmt.Println("Address of zzz.i2p:")
// Addresses change all the time
fmt.Println(addr)
Output: Address of zzz.i2p: GKapJ8koUcBj~jmQzHsTYxDg2tpfWj0xjQTzd8BhfC9c3OS5fwPBNajgF-eOD6eCjFTqTlorlh7Hnd8kXj1qblUGXT-tDoR9~YV8dmXl51cJn9MVTRrEqRWSJVXbUUz9t5Po6Xa247Vr0sJn27R4KoKP8QVj1GuH6dB3b6wTPbOamC3dkO18vkQkfZWUdRMDXk0d8AdjB0E0864nOT~J9Fpnd2pQE5uoFT6P0DqtQR2jsFvf9ME61aqLvKPPWpkgdn4z6Zkm-NJOcDz2Nv8Si7hli94E9SghMYRsdjU-knObKvxiagn84FIwcOpepxuG~kFXdD5NfsH0v6Uri3usE3uSzpWS0EHmrlfoLr5uGGd9ZHwwCIcgfOATaPRMUEQxiK9q48PS0V3EXXO4-YLT0vIfk4xO~XqZpn8~PW1kFe2mQMHd7oO89yCk-3yizRG3UyFtI7-mO~eCI6-m1spYoigStgoupnC3G85gJkqEjMm49gUjbhfWKWI-6NwTj0ZnAAAA
func (*Client) StreamAccept ¶
StreamAccept asks SAM to accept a TCP-Like connection
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