Documentation
¶
Index ¶
- Variables
- func AcquireTimer(timeout time.Duration) *time.Timer
- func IsEOF(err error) bool
- func Read(dst []byte, r io.Reader) ([]byte, error)
- func ReadSized(dst []byte, r io.Reader, max int) ([]byte, error)
- func ReleaseTimer(t *time.Timer)
- func Write(w io.Writer, buf []byte) error
- func WriteSized(w io.Writer, buf []byte) error
- type BufferedConn
- type Client
- type Conn
- type ConnState
- type ConnStateHandler
- type ConnStateHandlerFunc
- type Context
- type Handler
- type HandlerFunc
- type Handshaker
- type HandshakerFunc
- type Server
- type Session
- func (s *Session) DoClient(conn net.Conn) error
- func (s *Session) DoServer(conn net.Conn) error
- func (s *Session) Establish(ourPriv []byte) error
- func (s *Session) GenerateEphemeralKeys() ([]byte, []byte, error)
- func (s *Session) Read(conn net.Conn) error
- func (s *Session) SharedKey() []byte
- func (s *Session) Suite() cipher.AEAD
- func (s *Session) Write(conn net.Conn, ourPub []byte) error
- type SessionConn
- func (s *SessionConn) Close() error
- func (s *SessionConn) Flush() error
- func (s *SessionConn) LocalAddr() net.Addr
- func (s *SessionConn) Read(b []byte) (int, error)
- func (s *SessionConn) RemoteAddr() net.Addr
- func (s *SessionConn) SetDeadline(t time.Time) error
- func (s *SessionConn) SetReadDeadline(t time.Time) error
- func (s *SessionConn) SetWriteDeadline(t time.Time) error
- func (s *SessionConn) Write(b []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultClientSeqDelta uint32 = 2
View Source
var DefaultClientSeqOffset uint32 = 1
View Source
var DefaultDialTimeout = 3 * time.Second
View Source
var DefaultHandshakeTimeout = 3 * time.Second
View Source
var DefaultMaxClientConns = 4
View Source
var DefaultMaxConnWaitTimeout = 3 * time.Second
View Source
var DefaultMaxServerConns = 1024
View Source
var DefaultNumDialAttempts = 1
View Source
var DefaultReadBufferSize = 4096
View Source
var DefaultReadTimeout = 3 * time.Second
View Source
var DefaultSeqDelta uint32 = 2
View Source
var DefaultSeqOffset uint32 = 1
View Source
var DefaultServerSeqDelta uint32 = 2
View Source
var DefaultServerSeqOffset uint32 = 2
View Source
var DefaultWriteBufferSize = 4096
View Source
var DefaultWriteTimeout = 3 * time.Second
Functions ¶
func ReleaseTimer ¶
Types ¶
type BufferedConn ¶
type Client ¶
type Client struct { Addr string Handler Handler ConnState ConnStateHandler Handshaker Handshaker HandshakeTimeout time.Duration MaxConns int NumDialAttempts int ReadBufferSize int WriteBufferSize int DialTimeout time.Duration ReadTimeout time.Duration WriteTimeout time.Duration SeqOffset uint32 SeqDelta uint32 // contains filtered or unexported fields }
func (*Client) NumPendingWrites ¶
func (*Client) SendNoWait ¶
type Conn ¶
type Conn struct { Handler Handler ReadBufferSize int WriteBufferSize int ReadTimeout time.Duration WriteTimeout time.Duration SeqOffset uint32 SeqDelta uint32 // contains filtered or unexported fields }
func (*Conn) Handle ¶
func (c *Conn) Handle(done chan struct{}, conn BufferedConn) error
func (*Conn) NumPendingWrites ¶
func (*Conn) SendNoWait ¶
type ConnStateHandler ¶
type ConnStateHandlerFunc ¶
var DefaultConnStateHandler ConnStateHandlerFunc = func(conn *Conn, state ConnState) {}
func (ConnStateHandlerFunc) HandleConnState ¶
func (fn ConnStateHandlerFunc) HandleConnState(conn *Conn, state ConnState)
type HandlerFunc ¶
var DefaultHandler HandlerFunc = func(ctx *Context) error { return nil }
func (HandlerFunc) HandleMessage ¶
func (fn HandlerFunc) HandleMessage(ctx *Context) error
type Handshaker ¶
type Handshaker interface {
Handshake(conn net.Conn) (BufferedConn, error)
}
type HandshakerFunc ¶
type HandshakerFunc func(conn net.Conn) (BufferedConn, error)
var DefaultClientHandshaker HandshakerFunc = func(conn net.Conn) (BufferedConn, error) { var session Session err := session.DoClient(conn) if err != nil { return nil, err } return NewSessionConn(session.Suite(), conn), nil }
var DefaultServerHandshaker HandshakerFunc = func(conn net.Conn) (BufferedConn, error) { var session Session err := session.DoServer(conn) if err != nil { return nil, err } return NewSessionConn(session.Suite(), conn), nil }
func (HandshakerFunc) Handshake ¶
func (fn HandshakerFunc) Handshake(conn net.Conn) (BufferedConn, error)
type Server ¶
type Server struct { Handler Handler ConnState ConnStateHandler Handshaker Handshaker HandshakeTimeout time.Duration MaxConns int MaxConnWaitTimeout time.Duration ReadBufferSize int WriteBufferSize int ReadTimeout time.Duration WriteTimeout time.Duration SeqOffset uint32 SeqDelta uint32 // contains filtered or unexported fields }
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is not safe for concurrent use.
func (*Session) GenerateEphemeralKeys ¶
type SessionConn ¶
type SessionConn struct {
// contains filtered or unexported fields
}
SessionConn is not safe for concurrent use. It decrypts on reads and encrypts on writes via a provided cipher.AEAD suite for a given conn that implements net.Conn. It assumes all packets sent/received are to be prefixed with a 32-bit unsigned integer that designates the length of each individual packet.
The same cipher.AEAD suite must not be used for multiple SessionConn instances. Doing so will cause for plaintext data to be leaked.
func NewSessionConn ¶
func NewSessionConn(suite cipher.AEAD, conn net.Conn) *SessionConn
func (*SessionConn) Close ¶
func (s *SessionConn) Close() error
func (*SessionConn) Flush ¶
func (s *SessionConn) Flush() error
func (*SessionConn) LocalAddr ¶
func (s *SessionConn) LocalAddr() net.Addr
func (*SessionConn) RemoteAddr ¶
func (s *SessionConn) RemoteAddr() net.Addr
func (*SessionConn) SetDeadline ¶
func (s *SessionConn) SetDeadline(t time.Time) error
func (*SessionConn) SetReadDeadline ¶
func (s *SessionConn) SetReadDeadline(t time.Time) error
func (*SessionConn) SetWriteDeadline ¶
func (s *SessionConn) SetWriteDeadline(t time.Time) error
Click to show internal directories.
Click to hide internal directories.