Versions in this module Expand all Collapse all v1 v1.0.0 Nov 9, 2020 Changes in this version + const FECDataShards + const FECParityShards + const PacketHeaderSize + var ConvID uint32 = 555 + var ErrConnClosed = errors.New("connection is closed") + var ErrDifferentAddr = errors.New("different remote addr.") + var ErrExistConnection = errors.New("exist conneciton") + var ErrFecDataTimeout = errors.New("fec data timeout") + var ErrHeartbeatTimeout = errors.New("conn heartbeat timeout") + var ErrInvalidNonceSize = errors.New("invalid nonce size") + var ErrMessageAuthFailed = errors.New("message authentication failed") + var ErrNoFecData = errors.New("no fec data") + var ErrTryAgain = errors.New("try again") + var ErrUnknownFecCmd = errors.New("unknown fec cmd") + var ErrUnknownProtocolType = errors.New("unknown protocol type") + var ErrWriteDataTooLong = errors.New("write data too long") + var InitCryptoKey = []byte("0053A6F94C9FF24598EB3E91E4378ADD") + var InitCryptoNonce = []byte("0D74DB42A91077DEB3E91E43") + func SetDebugLogger(l Logger) + func SetMaxDataLengthLimit(n int) + type Chacha20poly1305Crypto struct + func NewChacha20poly1305CryptoCodec() *Chacha20poly1305Crypto + func (codec *Chacha20poly1305Crypto) Decrypt(src []byte) (dst []byte, err error) + func (codec *Chacha20poly1305Crypto) Encrypt(src []byte) (dst []byte, err error) + func (codec *Chacha20poly1305Crypto) SetKey(key []byte) + func (codec *Chacha20poly1305Crypto) SetReadNonce(nonce []byte) + func (codec *Chacha20poly1305Crypto) SetWriteNonce(nonce []byte) + type ClientConn struct + func NewClientConn(rwc net.PacketConn, addr net.Addr, handler ConnHandler) *ClientConn + func (conn *ClientConn) Start() error + func (conn *ClientConn) UseCryptoCodec(cryptoType CryptoType) + type ConnHandler interface + OnClosed func(err error) + OnNewDataComing func(data []byte) + OnReady func() + type CryptCodec interface + Decrypt func(src []byte) (dst []byte, err error) + Encrypt func(src []byte) (dst []byte, err error) + SetKey func(key []byte) + SetReadNonce func(nonce []byte) + SetWriteNonce func(nonce []byte) + type CryptoKeys struct + type CryptoNonce struct + type CryptoType byte + const UseChacha20 + const UseSalsa20 + type DataShards struct + type FecCodecDecoder struct + func NewFecDecoder(dataShards, parityShards, bufferSize int) *FecCodecDecoder + func (f *FecCodecDecoder) Decode(fecData []byte, now uint32) (rawData [][]byte, err error) + type FecCodecEncoder struct + func NewFecEncoder(dataShards, parityShards, bufferSize int) *FecCodecEncoder + func (f *FecCodecEncoder) Encode(rawData []byte) (fecData [][]byte, err error) + type Logger interface + Debug func(str string) + Debugf func(format string, v ...interface{}) + Error func(str string) + Errorf func(format string, v ...interface{}) + Fatal func(str string) + Fatalf func(format string, v ...interface{}) + Info func(str string) + Infof func(format string, v ...interface{}) + Warn func(str string) + Warnf func(format string, v ...interface{}) + type PlaintextData []byte + func (p PlaintextData) Data() []byte + func (p PlaintextData) Type() ProtoType + type ProtoType uint16 + type RawConn struct + func (conn *RawConn) Close() + func (conn *RawConn) EnableFEC() + func (conn *RawConn) ID() uint32 + func (conn *RawConn) IsClosed() bool + func (conn *RawConn) SetConnHandler(handler ConnHandler) + func (conn *RawConn) SetMTU(mtu int) bool + func (conn *RawConn) SetUpdateInterval(interval int) + func (conn *RawConn) SetWindow(sndWnd, rcvWnd int) + func (conn *RawConn) StartKCPStatus() + func (conn *RawConn) StopKCPStatus() + func (conn *RawConn) Write(data []byte) (int, error) + type Salsa20Crypto struct + func NewSalsa20CryptoCodec() *Salsa20Crypto + func (codec *Salsa20Crypto) Decrypt(src []byte) (dst []byte, err error) + func (codec *Salsa20Crypto) Encrypt(src []byte) (dst []byte, err error) + func (codec *Salsa20Crypto) SetKey(key []byte) + func (codec *Salsa20Crypto) SetReadNonce(nonce []byte) + func (codec *Salsa20Crypto) SetWriteNonce(nonce []byte) + type Server struct + func NewServer(rwc net.PacketConn, handler ServerHandler, parallelCount uint32) *Server + func (s *Server) Close() + func (s *Server) Start() + func (s *Server) UseCryptoCodec(cryptoType CryptoType) + type ServerConn struct + type ServerHandler interface + OnClosed func(err error) + OnConnClosed func(conn *ServerConn, err error) + OnNewConnComing func(conn *ServerConn) + type Task struct + type TaskList []*Task + func (t *TaskList) Pop() interface{} + func (t *TaskList) Push(v interface{}) + func (t TaskList) Len() int + func (t TaskList) Less(i int, j int) bool + func (t TaskList) Swap(i int, j int) + type TimerScheduler struct + func NewTimerScheduler(parallelCount uint32) *TimerScheduler + func (ts *TimerScheduler) Close() + func (ts *TimerScheduler) PushTask(exec func(), t uint32)