Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( HandshakeData = []byte("EMUX ") DefaultClientHandshake = NewHandshake(HandshakeData, true) DefaultServerHandshake = NewHandshake(HandshakeData, false) DefaultTimeout = 10 * time.Second )
DefaultHandshake 0 5 +---------+---------+---------+---------+---------+ | "EMUX " | +---------+---------+---------+---------+---------+
View Source
var ( ErrClosed = net.ErrClosed ErrAlreadyStarted = fmt.Errorf("session already started") )
View Source
var DefaultInstruction = Instruction{ Close: 0x00, Connect: 0xa0, Connected: 0xa1, Disconnect: 0xc0, Disconnected: 0xc1, Data: 0xb0, MaxDataPacketSize: bufSize - 1 - 2*binary.MaxVarintLen64, }
View Source
var (
ErrTimeout = fmt.Errorf("timeout")
)
Functions ¶
This section is empty.
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 ¶
type Decode struct {
DecodeReader
}
func NewDecode ¶
func NewDecode(r DecodeReader) *Decode
func (*Decode) ReadUvarint ¶
type DecodeReader ¶ added in v0.1.0
type DecodeReader interface { io.Reader io.ByteReader }
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 Retry int // contains filtered or unexported fields }
func (*DialerSession) DialContext ¶
type Encode ¶
type Encode struct { EncodeWriter // contains filtered or unexported fields }
func NewEncode ¶
func NewEncode(w EncodeWriter) *Encode
func (*Encode) WriteBytes ¶
func (*Encode) WriteUvarint ¶
type EncodeWriter ¶ added in v0.1.0
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 }
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 // 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 // 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.