Documentation
¶
Index ¶
- Variables
- func NewShaperQueue() *shaperQueue
- func VerifyConfig(config *Config) error
- type Allocator
- type CLASSID
- type Config
- type Frame
- type Session
- func (s *Session) Accept() (io.ReadWriteCloser, error)
- func (s *Session) AcceptStream() (*Stream, error)
- func (s *Session) Close() error
- func (s *Session) CloseChan() <-chan struct{}
- func (s *Session) IsClosed() bool
- func (s *Session) LocalAddr() net.Addr
- func (s *Session) NumStreams() int
- func (s *Session) Open() (io.ReadWriteCloser, error)
- func (s *Session) OpenStream() (*Stream, error)
- func (s *Session) RemoteAddr() net.Addr
- func (s *Session) SetDeadline(t time.Time) error
- type Stream
- func (s Stream) Close() error
- func (s Stream) CloseWrite() error
- func (s Stream) GetDieCh() <-chan struct{}
- func (s Stream) ID() uint32
- func (s Stream) LocalAddr() net.Addr
- func (s Stream) Read(b []byte) (n int, err error)
- func (s Stream) RemoteAddr() net.Addr
- func (s Stream) SetDeadline(t time.Time) error
- func (s Stream) SetReadDeadline(t time.Time) error
- func (s Stream) SetWriteDeadline(t time.Time) error
- func (s Stream) Write(b []byte) (n int, err error)
- func (s Stream) WriteTo(w io.Writer) (n int64, err error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidProtocol = errors.New("invalid protocol") ErrConsumed = errors.New("peer consumed more than sent") ErrGoAway = errors.New("stream id overflows, should start a new connection") ErrTimeout net.Error = &timeoutError{} ErrWouldBlock = errors.New("operation would block on IO") )
Functions ¶
func NewShaperQueue ¶ added in v1.5.36
func NewShaperQueue() *shaperQueue
NewShaperQueue creates an empty queue for fairly scheduling stream writes.
func VerifyConfig ¶
VerifyConfig reports whether config contains valid session settings.
Types ¶
type Allocator ¶ added in v1.3.1
type Allocator struct {
// contains filtered or unexported fields
}
Allocator pools byte slices for incoming frames.
func NewAllocator ¶ added in v1.3.1
func NewAllocator() *Allocator
NewAllocator creates a byte-slice allocator for frames up to 65536 bytes. Allocations use power-of-two capacities, wasting less than half the capacity.
type Config ¶
type Config struct {
// Version is the smux protocol version: 1 or 2.
Version int
// KeepAliveDisabled disables keep-alive messages and timeout checks.
KeepAliveDisabled bool
// KeepAliveInterval is the interval between NOP keep-alive messages.
KeepAliveInterval time.Duration
// KeepAliveTimeout is the maximum time without received data before the
// session is closed.
KeepAliveTimeout time.Duration
// MaxFrameSize is the maximum frame payload size sent to the peer.
MaxFrameSize int
// MaxReceiveBuffer is the maximum amount of data buffered across all streams.
MaxReceiveBuffer int
// MaxStreamBuffer is the receive-window size advertised for each stream in
// protocol version 2.
MaxStreamBuffer int
}
Config contains the settings used to create a smux session.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default session configuration.
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
Frame represents a packet multiplexed over a single connection.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session manages streams multiplexed over a single connection.
func Client ¶
func Client(conn io.ReadWriteCloser, config *Config) (*Session, error)
Client initializes a new client-side session over conn.
func Server ¶
func Server(conn io.ReadWriteCloser, config *Config) (*Session, error)
Server initializes a new server-side session over conn.
func (*Session) Accept ¶ added in v1.4.0
func (s *Session) Accept() (io.ReadWriteCloser, error)
Accept returns the next stream as a generic io.ReadWriteCloser.
func (*Session) AcceptStream ¶
AcceptStream waits for and returns the next incoming stream.
func (*Session) CloseChan ¶ added in v1.5.17
func (s *Session) CloseChan() <-chan struct{}
CloseChan returns a channel that is closed when the session shuts down.
func (*Session) LocalAddr ¶ added in v1.3.2
LocalAddr returns the underlying connection's local address, if available.
func (*Session) NumStreams ¶
NumStreams returns the number of streams currently registered in the session.
func (*Session) Open ¶ added in v1.4.1
func (s *Session) Open() (io.ReadWriteCloser, error)
Open opens a stream and returns it as an io.ReadWriteCloser.
func (*Session) OpenStream ¶
OpenStream opens a new stream on the session.
func (*Session) RemoteAddr ¶ added in v1.3.2
RemoteAddr returns the underlying connection's remote address, if available.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream is a wrapper around stream that exposes the public API.
func (Stream) Close ¶
func (s Stream) Close() error
Close implements net.Conn Close fully closes the stream (both read and write sides).
func (Stream) CloseWrite ¶ added in v1.5.54
func (s Stream) CloseWrite() error
CloseWrite implements half-close by closing the write side of the stream. After CloseWrite, the stream can still receive data from the peer, but any further writes will return io.ErrClosedPipe. This is similar to net.TCPConn.CloseWrite().
func (Stream) GetDieCh ¶ added in v1.0.8
func (s Stream) GetDieCh() <-chan struct{}
GetDieCh returns a channel that is closed when the stream is closed.
func (Stream) ID ¶ added in v1.0.5
func (s Stream) ID() uint32
ID returns the stream's unique identifier.
func (Stream) LocalAddr ¶ added in v1.0.4
LocalAddr returns the underlying connection's local address, if available.
func (Stream) RemoteAddr ¶ added in v1.0.4
RemoteAddr returns the underlying connection's remote address, if available.
func (Stream) SetDeadline ¶ added in v1.0.4
SetDeadline sets both read and write deadlines as defined by net.Conn.SetDeadline. A zero time value disables the deadlines.
func (Stream) SetReadDeadline ¶ added in v1.0.4
SetReadDeadline sets the read deadline as defined by net.Conn.SetReadDeadline. A zero time value disables the deadline.
func (Stream) SetWriteDeadline ¶ added in v1.0.4
SetWriteDeadline sets the write deadline as defined by net.Conn.SetWriteDeadline. A zero time value disables the deadline.
func (Stream) Write ¶
Write implements net.Conn
Concurrent Write calls may interleave at frame boundaries, and their ordering is nondeterministic.
