mirror of
https://github.com/go-i2p/goSam.git
synced 2025-06-09 09:32:59 -04:00
Edited Comments according to golint
This commit is contained in:
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
2
dial.go
2
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 {
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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))
|
||||
|
Reference in New Issue
Block a user