Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrClosed = net.ErrClosed ErrTimeout = fmt.Errorf("timeout") ErrAlreadyStarted = fmt.Errorf("session already started") )
View Source
var ( HandshakeData = []byte("EMUX ") DefaultClientHandshake = NewHandshake(HandshakeData, true) DefaultServerHandshake = NewHandshake(HandshakeData, false) )
DefaultHandshake 0 5 +---------+---------+---------+---------+---------+ | "EMUX " | +---------+---------+---------+---------+---------+
View Source
var ( DefaultInstruction = Instruction{ Close: 0x00, Connect: 0xa0, Connected: 0xa1, Disconnect: 0xc0, Disconnected: 0xc1, Data: 0xb0, MaxDataPacketSize: bufSize - 1 - 2*binary.MaxVarintLen64, } DefaultTimeout = 30 * time.Second DefaultIdleTimeout = 600 * time.Second )
Functions ¶
Types ¶
type Client ¶ added in v0.0.12
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶ added in v0.0.12
func NewClient(ctx context.Context, stm io.ReadWriteCloser, instruction *Instruction) *Client
type Decode ¶
func (*Decode) ReadUvarint ¶
type Dialer ¶
type Dialer interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error)
}
Dialer contains options for connecting to an address.
type DialerSession ¶
type DialerSession struct { BytesPool BytesPool Logger Logger Handshake Handshake Instruction Instruction Timeout time.Duration IdleTimeout time.Duration Retry int // contains filtered or unexported fields }
func (*DialerSession) Close ¶ added in v0.2.0
func (d *DialerSession) Close() error
func (*DialerSession) DialContext ¶
type Handshake ¶
type Handshake interface {
Handshake(ctx context.Context, rw io.ReadWriter) error
}
func NewHandshake ¶
type Instruction ¶ added in v0.0.13
type Instruction struct { Close uint8 // close all sessions and connections, only command Connect uint8 // create a connect stream, with both command and stream id Connected uint8 // reply to connect, with both command and stream id Disconnect uint8 // disconnect a stream and report the reason, with both command and stream id Disconnected uint8 // reply to disconnect, with both command and stream id Data uint8 // data packet, all fields MaxDataPacketSize uint64 // max data packet size }
func (Instruction) Info ¶ added in v0.2.0
func (i Instruction) Info(cmd uint8) string
type ListenConfig ¶
type ListenConfig interface {
Listen(ctx context.Context, network, address string) (net.Listener, error)
}
ListenConfig contains options for listening to an address.
type ListenConfigSession ¶
type ListenConfigSession struct { Logger Logger BytesPool BytesPool Handshake Handshake Instruction Instruction Timeout time.Duration IdleTimeout time.Duration // contains filtered or unexported fields }
func NewListenConfig ¶ added in v0.1.0
func NewListenConfig(ctx context.Context, listener ListenConfig) *ListenConfigSession
type ListenerSession ¶
type ListenerSession struct { BytesPool BytesPool Logger Logger Handshake Handshake Instruction Instruction Timeout time.Duration IdleTimeout time.Duration // contains filtered or unexported fields }
func NewListener ¶
func NewListener(ctx context.Context, listener net.Listener) *ListenerSession
func (*ListenerSession) Addr ¶
func (l *ListenerSession) Addr() net.Addr
func (*ListenerSession) Close ¶
func (l *ListenerSession) Close() error
func (*ListenerSession) IsClosed ¶ added in v0.1.3
func (l *ListenerSession) IsClosed() bool
type Logger ¶
type Logger interface {
Println(v ...interface{})
}
Logger is the interface for logging.
type Server ¶ added in v0.0.12
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶ added in v0.0.12
func NewServer(ctx context.Context, stm io.ReadWriteCloser, instruction *Instruction) *Server
Click to show internal directories.
Click to hide internal directories.