Documentation
¶
Index ¶
- Constants
- Variables
- func NewDatagramBufferedPipe() *datagramBufferedPipe
- func NewStreamBuffer() *streamBuffer
- func NewStreamBufferedPipe() *streamBufferedPipe
- type Frame
- type LimitedValve
- type Obfuscator
- type Session
- func (sesh *Session) Accept() (net.Conn, error)
- func (sesh *Session) AddConnection(conn net.Conn)
- func (sesh *Session) Addr() net.Addr
- func (sesh *Session) Close() error
- func (sesh *Session) GetSessionKey() [32]byte
- func (sesh *Session) IsClosed() bool
- func (sesh *Session) OpenStream() (*Stream, error)
- func (sesh *Session) SetTerminalMsg(msg string)
- func (sesh *Session) TerminalMsg() string
- type SessionConfig
- type Stream
- func (s *Stream) Close() error
- func (s *Stream) LocalAddr() net.Addr
- func (s *Stream) Read(buf []byte) (n int, err error)
- func (s *Stream) ReadFrom(r io.Reader) (n int64, 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) SetReadFromTimeout(d time.Duration)
- func (s *Stream) SetWriteDeadline(t time.Time) error
- func (s *Stream) SetWriteToTimeout(d time.Duration)
- func (s *Stream) Write(in []byte) (n int, err error)
- func (s *Stream) WriteTo(w io.Writer) (int64, error)
- type UnlimitedValve
- type Valve
Constants ¶
const ( EncryptionMethodPlain = iota EncryptionMethodAES256GCM EncryptionMethodChaha20Poly1305 EncryptionMethodAES128GCM )
Variables ¶
var ErrBrokenSession = errors.New("broken session")
var ErrBrokenStream = errors.New("broken stream")
var ErrTimeout = errors.New("deadline exceeded")
var UNLIMITED_VALVE = &UnlimitedValve{}
Functions ¶
func NewDatagramBufferedPipe ¶
func NewDatagramBufferedPipe() *datagramBufferedPipe
func NewStreamBuffer ¶
func NewStreamBuffer() *streamBuffer
streamBuffer is a wrapper around streamBufferedPipe. Its main function is to sort frames in order, and wait for frames to arrive if they have arrived out-of-order. Then it writes the payload of frames into a streamBufferedPipe.
func NewStreamBufferedPipe ¶
func NewStreamBufferedPipe() *streamBufferedPipe
Types ¶
type LimitedValve ¶
type LimitedValve struct {
// contains filtered or unexported fields
}
Valve needs to be universal, across all sessions that belong to a user
func MakeValve ¶
func MakeValve(rxRate, txRate int64) *LimitedValve
func (*LimitedValve) AddRx ¶
func (v *LimitedValve) AddRx(n int64)
func (*LimitedValve) AddTx ¶
func (v *LimitedValve) AddTx(n int64)
func (*LimitedValve) GetRx ¶
func (v *LimitedValve) GetRx() int64
func (*LimitedValve) GetTx ¶
func (v *LimitedValve) GetTx() int64
func (*LimitedValve) Nullify ¶
func (v *LimitedValve) Nullify() (int64, int64)
type Obfuscator ¶
type Obfuscator struct {
// contains filtered or unexported fields
}
Obfuscator is responsible for serialisation, obfuscation, and optional encryption of data frames.
func MakeObfuscator ¶
func MakeObfuscator(encryptionMethod byte, sessionKey [32]byte) (o Obfuscator, err error)
type Session ¶
type Session struct { SessionConfig // contains filtered or unexported fields }
A Session represents a self-contained communication chain between local and remote. It manages its streams, controls serialisation and encryption of data sent and received using the supplied Obfuscator, and send and receive data through a manged connection pool filled with underlying connections added to it.
func MakeSession ¶
func MakeSession(id uint32, config SessionConfig) *Session
func (*Session) Accept ¶
Accept is similar to net.Listener's Accept(). It blocks and returns an incoming stream
func (*Session) AddConnection ¶
AddConnection is used to add an underlying connection to the connection pool
func (*Session) GetSessionKey ¶
func (*Session) OpenStream ¶
OpenStream is similar to net.Dial. It opens up a new stream
func (*Session) SetTerminalMsg ¶
func (*Session) TerminalMsg ¶
type SessionConfig ¶
type SessionConfig struct { Obfuscator // Valve is used to limit transmission rates, and record and limit usage Valve Unordered bool // A Singleplexing session always has just one stream Singleplex bool // maximum size of an obfuscated frame, including headers and overhead MsgOnWireSizeLimit int // InactivityTimeout sets the duration a Session waits while it has no active streams before it closes itself InactivityTimeout time.Duration }
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream implements net.Conn. It represents an optionally-ordered, full-duplex, self-contained connection. If the session it belongs to runs in ordered mode, it provides ordering guarantee regardless of the underlying connection used. If the underlying connections the session uses are reliable, Stream is reliable. If they are not, Stream does not guarantee reliability.
func (*Stream) Close ¶
active close. Close locally and tell the remote that this stream is being closed
func (*Stream) ReadFrom ¶
ReadFrom continuously read data from r and send it off, until either r returns error or nothing has been read for readFromTimeout amount of time
func (*Stream) RemoteAddr ¶
func (*Stream) SetDeadline ¶
the following functions are purely for implementing net.Conn interface. they are not used TODO: implement the following
func (*Stream) SetReadFromTimeout ¶
func (*Stream) SetWriteToTimeout ¶
type UnlimitedValve ¶
type UnlimitedValve struct{}
func (*UnlimitedValve) AddRx ¶
func (v *UnlimitedValve) AddRx(n int64)
func (*UnlimitedValve) AddTx ¶
func (v *UnlimitedValve) AddTx(n int64)
func (*UnlimitedValve) GetRx ¶
func (v *UnlimitedValve) GetRx() int64
func (*UnlimitedValve) GetTx ¶
func (v *UnlimitedValve) GetTx() int64
func (*UnlimitedValve) Nullify ¶
func (v *UnlimitedValve) Nullify() (int64, int64)