diff --git a/accept.go b/accept.go index 3117915..dbc1ce6 100644 --- a/accept.go +++ b/accept.go @@ -5,7 +5,7 @@ import ( "net" ) -// creates a new Client and Accept a connection on it +// Accept creates a new Client and accepts a connection on it func (c *Client) Accept() (net.Conn, error) { id, newAddr, err := c.CreateStreamSession("") if err != nil { diff --git a/client.go b/client.go index 805be13..d33fc2f 100644 --- a/client.go +++ b/client.go @@ -13,12 +13,12 @@ type Client struct { verbose bool } -// create a new client, connecting to the default host:port at localhost:7656 +// NewDefaultClient creates a new client, connecting to the default host:port at localhost:7656 func NewDefaultClient() (*Client, error) { return NewClient("localhost:7656") } -// create a new client, connecting to a specified port +// NewClient creates a new client, connecting to a specified port func NewClient(addr string) (*Client, error) { conn, err := net.Dial("tcp", addr) if err != nil { @@ -28,7 +28,8 @@ func NewClient(addr string) (*Client, error) { return c, c.hello() } -// switches logging on or off. (also passed to new clients inside Dial.) +// ToggleVerbose switches logging on or off. +// (also passed to new clients inside Dial.) func (c *Client) ToggleVerbose() { c.verbose = !c.verbose } diff --git a/dial.go b/dial.go index 017a647..e6af1fe 100644 --- a/dial.go +++ b/dial.go @@ -5,7 +5,7 @@ import ( "strings" ) -// Implements the net.Dial function can be used for http.Transport +// Dial implements the net.Dial function and can be used for http.Transport func (c *Client) Dial(network, addr string) (net.Conn, error) { portIdx := strings.Index(addr, ":") if portIdx >= 0 { diff --git a/naming.go b/naming.go index 492c9f5..288f46d 100644 --- a/naming.go +++ b/naming.go @@ -4,6 +4,7 @@ import ( "fmt" ) +// Lookup askes SAM for the internal i2p address from name func (c *Client) Lookup(name string) (addr string, err error) { var r *Reply diff --git a/replyParser.go b/replyParser.go index f496557..2b8c497 100644 --- a/replyParser.go +++ b/replyParser.go @@ -9,7 +9,7 @@ import ( 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 : + 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.) @@ -18,7 +18,7 @@ const ( ResultTimeout = "TIMEOUT" // Timeout while waiting for an event (e.g. peer answer) ) -// Custom error type, containing the Result and full Reply +// A ReplyError is a custom error type, containing the Result and full Reply type ReplyError struct { Result string Reply *Reply @@ -28,7 +28,7 @@ func (r ReplyError) Error() string { return fmt.Sprintf("ReplyError: Result:%s - Reply:%+v", r.Result, r.Reply) } -// Parsed Reply type containing a map of all the key-value pairs +// Reply is the parsed result of a SAM command, containing a map of all the key-value pairs type Reply struct { Topic string Type string diff --git a/sessions.go b/sessions.go index 6602ccc..77147d6 100644 --- a/sessions.go +++ b/sessions.go @@ -6,7 +6,8 @@ import ( "math/rand" ) -// Create a new STREAM Session. Returns the Id for the new Client. +// CreateStreamSession creates a new STREAM Session. +// Returns the Id for the new Client. func (c *Client) CreateStreamSession(dest string) (id int32, newDest string, err error) { if dest == "" { dest = "TRANSIENT" diff --git a/stream.go b/stream.go index 3bf9825..92f63c6 100644 --- a/stream.go +++ b/stream.go @@ -4,7 +4,7 @@ import ( "fmt" ) -// Asks SAM for a TCP-Like connection to dest, has to be called on a new Client +// StreamConnect asks SAM for a TCP-Like connection to dest, has to be called on a new Client func (c *Client) StreamConnect(id int32, dest string) (err error) { var r *Reply @@ -25,7 +25,7 @@ func (c *Client) StreamConnect(id int32, dest string) (err error) { return nil } -// Ask SAM to accept a TCP-Like connection +// StreamAccept asks SAM to accept a TCP-Like connection func (c *Client) StreamAccept(id int32) (r *Reply, err error) { r, err = c.sendCmd(fmt.Sprintf("STREAM ACCEPT ID=%d SILENT=false", id))