Documentation ¶
Overview ¶
Package client implements a DTLS based client for Span
Sample usage:
package main import ( "log" "time" client "github.com/borud/go-span-client" ) func main() { client, err := client.Connect(client.NewDefaultConfig()) if err != nil { log.Fatal(err) } defer client.Close() n, err := client.Write([]byte("this is a test"), time.Second) if err != nil { log.Fatal(err) } log.Printf("wrote %d bytes", n) buffer := make([]byte, 1024) n, err = client.Read(buffer, time.Second*5) if err != nil { log.Fatal(err) } log.Printf("read %d bytes: [%s]", n, string(buffer)) }
/
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrCannotResolveSpanAddress = errors.New("cannot resolve Span address") ErrCannotConnect = errors.New("cannot connect to Span") ErrCannotReadKeyPair = errors.New("cannot read keypair") ErrCannotLoadCertPool = errors.New("cannot load certpool") )
Errors for Client
Functions ¶
func COAPConnect ¶
func COAPConnect(config Config) (*client.ClientConn, error)
COAPConnect creates a CoAP connection.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Span client that connects as a device.
type Config ¶
Config for Client.
func NewConfig ¶
NewConfig creates a new configuration from certBytes and keyBytes. Note that both certBytes and keyBytes are expected to be PEM-encoded.
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig creates a new default configuration. This requires you to have a .devcli/certs directory under your home directory where the cert.crt and key.pem are stored. This function is a bit ugly since it terminates if anything goes wrong, so it is only useful in clients where this behavior is acceptable. If you want to be able to do proper error handling please see the NewConfig function.