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
func VerifyConfig ¶
VerifyConfig is used to verify the sanity of configuration
Types ¶
type Allocator ¶ added in v1.3.1
type Allocator struct {
// contains filtered or unexported fields
}
Allocator for incoming frames, optimized to prevent overwriting after zeroing
func NewAllocator ¶ added in v1.3.1
func NewAllocator() *Allocator
NewAllocator initiates a []byte allocator for frames less than 65536 bytes, the waste(memory fragmentation) of space allocation is guaranteed to be no more than 50%.
type Config ¶
type Config struct {
// SMUX Protocol version, support 1,2
Version int
// Disabled keepalive
KeepAliveDisabled bool
// KeepAliveInterval is how often to send a NOP command to the remote
KeepAliveInterval time.Duration
// KeepAliveTimeout is how long the session
// will be closed if no data has arrived
KeepAliveTimeout time.Duration
// MaxFrameSize is used to control the maximum
// frame size to sent to the remote
MaxFrameSize int
// MaxReceiveBuffer is used to control the maximum
// number of data in the buffer pool
MaxReceiveBuffer int
// MaxStreamBuffer is used to control the maximum
// number of data per stream
MaxStreamBuffer int
}
Config is used to tune the Smux session
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig is used to return a default configuration
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
Frame defines a packet from or to be multiplexed into a single connection
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session defines a multiplexed connection for streams
func Client ¶
func Client(conn io.ReadWriteCloser, config *Config) (*Session, error)
Client is used to initialize a new client-side connection.
func Server ¶
func Server(conn io.ReadWriteCloser, config *Config) (*Session, error)
Server is used to initialize a new server-side connection.
func (*Session) Accept ¶ added in v1.4.0
func (s *Session) Accept() (io.ReadWriteCloser, error)
Accept Returns a generic ReadWriteCloser instead of smux.Stream
func (*Session) AcceptStream ¶
AcceptStream is used to block until the next available stream is ready to be accepted.
func (*Session) CloseChan ¶ added in v1.5.17
func (s *Session) CloseChan() <-chan struct{}
CloseChan can be used by someone who wants to be notified immediately when this session is closed
func (*Session) NumStreams ¶
NumStreams returns the number of currently open streams
func (*Session) Open ¶ added in v1.4.1
func (s *Session) Open() (io.ReadWriteCloser, error)
Open returns a generic ReadWriteCloser
func (*Session) OpenStream ¶
OpenStream is used to create a new stream
func (*Session) RemoteAddr ¶ added in v1.3.2
RemoteAddr satisfies net.Conn interface
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
wrapper for GC
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 readonly chan which can be readable when the stream is to be closed.
func (Stream) ID ¶ added in v1.0.5
func (s Stream) ID() uint32
ID returns the stream's unique identifier.
func (Stream) RemoteAddr ¶ added in v1.0.4
RemoteAddr satisfies net.Conn interface
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
Note that the behavior when multiple goroutines write concurrently is not deterministic, frames may interleave in random way.
func (Stream) WriteTo ¶ added in v1.4.5
WriteTo implements io.WriteTo WriteTo writes data to w until there's no more data to write or when an error occurs. The return value n is the number of bytes written. Any error encountered during the write is also returned. WriteTo calls Write in a loop until there is no more data to write or when an error occurs. If the underlying stream is a v2 stream, it will send window update to peer when necessary. If the underlying stream is a v1 stream, it will not send window update to peer.
