Documentation
¶
Index ¶
- Constants
- func ConnWrapper(conns []net.Conn, wrapper func(conn net.Conn) net.Conn) []net.Conn
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func Dial(network, addr string, tunnels int) ([]net.Conn, error)
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func RemoveElement(slice []net.Conn, index int) []net.Conn
- func SetLevel(l Level)
- func SetLogger(l Logger)
- func SetNoOutputLogger()
- func WaitWithContext(wg *sync.WaitGroup, ctx context.Context) error
- func Warn(v ...interface{})
- func Warnf(format string, v ...interface{})
- type Config
- type ControlMsg
- type Frame
- type Level
- type Listener
- type Logger
- type SafeBuffer
- type Session
- type Stream
- func (s *Stream) Close() error
- func (s *Stream) CloseRead() error
- func (s *Stream) CloseWrite() error
- func (s *Stream) Deliver(data []byte, idx uint64, isEOF bool) error
- func (s *Stream) IsClosed() bool
- func (s *Stream) IsReadClosed() bool
- func (s *Stream) IsWriteClosed() bool
- func (s *Stream) LocalAddr() net.Addr
- func (s *Stream) PutBuffer(buf []byte)
- 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)
Constants ¶
const ( SESSION_BUFFER_SIZE = STREAM_BUFFER_SIZE + 1024 // Extra 1KB for session header CONTROL_STREAM_ID = "0" CONTROL_TYPE_OPEN_STREAM = "OPEN_STREAM" CONTROL_STREAM_CONFIRMED = "STREAM_CONFIRMED" )
const STREAM_BUFFER_SIZE = 32 * 1024 // 32KB buffer size
Variables ¶
This section is empty.
Functions ¶
func ConnWrapper ¶
func SetLevel ¶ added in v0.2.1
func SetLevel(l Level)
SetLevel sets the global minimum logging level. Messages below this level will be ignored by the default logger. If a custom logger is set it is up to that implementation to respect levels.
func SetLogger ¶ added in v0.2.1
func SetLogger(l Logger)
SetLogger sets the package-wide logger. Passing nil resets to default.
func SetNoOutputLogger ¶ added in v0.2.1
func SetNoOutputLogger()
SetNoOutputLogger sets a logger that discards all output.
Types ¶
type Config ¶
type Config struct {
KeepAliveInterval time.Duration
KeepAliveTimeout time.Duration
Tunnels int32
Timeout time.Duration
}
func DefaultConfig ¶
func DefaultConfig() *Config
type ControlMsg ¶
type Listener ¶
func ListenWithCustomFunc ¶
type Logger ¶ added in v0.2.1
type Logger interface {
Debug(v ...interface{})
Info(v ...interface{})
Warn(v ...interface{})
Error(v ...interface{})
Debugf(format string, v ...interface{})
Infof(format string, v ...interface{})
Warnf(format string, v ...interface{})
Errorf(format string, v ...interface{})
}
Logger is the interface users can implement to provide custom logging. It includes leveled methods and formatters.
type SafeBuffer ¶ added in v0.3.0
type SafeBuffer struct {
// contains filtered or unexported fields
}
func (*SafeBuffer) Len ¶ added in v0.3.0
func (sb *SafeBuffer) Len() int
func (*SafeBuffer) ReadWhenNotEmpty ¶ added in v0.3.0
func (sb *SafeBuffer) ReadWhenNotEmpty(p []byte) (n int, err error)
func (*SafeBuffer) Reset ¶ added in v0.3.2
func (sb *SafeBuffer) Reset()
type Session ¶
type Session struct {
ID string
LocalAddr net.Addr
RemoteAddr net.Addr
// contains filtered or unexported fields
}
func (*Session) AcceptStream ¶
func (*Session) NumStreams ¶
func (*Session) OpenStream ¶
type Stream ¶
type Stream struct {
ID string
ReadBuf *SafeBuffer
WriteBuf chan []byte
ReadIndex atomic.Uint64 // Received data index
WriteIndex atomic.Uint64 // Sent data index
UnorderedBuf map[uint64][]byte
Finalize func(StreamID string)
// contains filtered or unexported fields
}
func (*Stream) CloseRead ¶
In the most cases, CloseRead is called when EOF is received from remote side.
func (*Stream) CloseWrite ¶
CloseWrite closes the write end of the stream. Can be used to signal EOF to the remote side. You need to call CloseRead to prevent resource leak when EOF from remote side isn't received. (e.g., setting a timeout and closing the stream)
func (*Stream) IsReadClosed ¶ added in v0.1.6
func (*Stream) IsWriteClosed ¶ added in v0.1.6
func (*Stream) RemoteAddr ¶
RemoteAddr returns the remote network address, if known.
func (*Stream) SetDeadline ¶
SetDeadline sets the read and write deadlines associated with the stream. Currently not implemented for mtmux streams.
func (*Stream) SetReadDeadline ¶
SetReadDeadline sets the deadline for future Read calls. Currently not implemented for mtmux streams.
func (*Stream) SetWriteDeadline ¶
SetWriteDeadline sets the deadline for future Write calls. Currently not implemented for mtmux streams.