Documentation
¶
Index ¶
- Constants
- Variables
- func SetDebugLogger(l Logger)
- func SetMaxDataLengthLimit(n int)
- type 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
- type ConnHandler
- type CryptCodec
- type CryptoKeys
- type CryptoNonce
- type CryptoType
- type DataShards
- type FecCodecDecoder
- type FecCodecEncoder
- type Logger
- type PlaintextData
- type ProtoType
- type RawConn
- 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
- 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
- type ServerConn
- type ServerHandler
- type Task
- type TaskList
- type TimerScheduler
Constants ¶
View Source
const ( FECDataShards = 3 FECParityShards = 2 )
View Source
const (
PacketHeaderSize uint16 = macSize + protoSize
)
packet protocol: raw data -> kcp data -> [compress] -> crypto -> fec
Variables ¶
View Source
var ( InitCryptoKey = []byte("0053A6F94C9FF24598EB3E91E4378ADD") InitCryptoNonce = []byte("0D74DB42A91077DEB3E91E43") )
View Source
var ( ErrConnClosed = errors.New("connection is closed") ErrDifferentAddr = errors.New("different remote addr.") ErrMessageAuthFailed = errors.New("message authentication failed") ErrHeartbeatTimeout = errors.New("conn heartbeat timeout") ErrInvalidNonceSize = errors.New("invalid nonce size") ErrTryAgain = errors.New("try again") ErrWriteDataTooLong = errors.New("write data too long") ErrUnknownProtocolType = errors.New("unknown protocol type") ErrExistConnection = errors.New("exist conneciton") )
View Source
var ( ErrUnknownFecCmd = errors.New("unknown fec cmd") ErrFecDataTimeout = errors.New("fec data timeout") ErrNoFecData = errors.New("no fec data") )
View Source
var ConvID uint32 = 555
Functions ¶
func SetDebugLogger ¶
func SetDebugLogger(l Logger)
func SetMaxDataLengthLimit ¶
func SetMaxDataLengthLimit(n int)
Types ¶
type Chacha20poly1305Crypto ¶
type Chacha20poly1305Crypto struct {
// contains filtered or unexported fields
}
func NewChacha20poly1305CryptoCodec ¶
func NewChacha20poly1305CryptoCodec() *Chacha20poly1305Crypto
In chacha20poly1305, data format is |---DATA---|---MAC---| In gouxp, data format is |---MAC---|---DATA---| When use chacha20poly1305, must modify data format to adapt chacha20poly1305. Chacha20poly1305 use 12bytes nonce In other way, you can use poly1305 + salsa20/chacha20 to avoid move origin data
func (*Chacha20poly1305Crypto) Decrypt ¶
func (codec *Chacha20poly1305Crypto) Decrypt(src []byte) (dst []byte, err error)
func (*Chacha20poly1305Crypto) Encrypt ¶
func (codec *Chacha20poly1305Crypto) Encrypt(src []byte) (dst []byte, err error)
change data format |---MAC---|---DATA---| to |---DATA---|---MAC---|
func (*Chacha20poly1305Crypto) SetKey ¶
func (codec *Chacha20poly1305Crypto) SetKey(key []byte)
func (*Chacha20poly1305Crypto) SetReadNonce ¶
func (codec *Chacha20poly1305Crypto) SetReadNonce(nonce []byte)
func (*Chacha20poly1305Crypto) SetWriteNonce ¶
func (codec *Chacha20poly1305Crypto) SetWriteNonce(nonce []byte)
type ClientConn ¶
type ClientConn struct { RawConn // contains filtered or unexported fields }
func NewClientConn ¶
func NewClientConn(rwc net.PacketConn, addr net.Addr, handler ConnHandler) *ClientConn
func (*ClientConn) Start ¶
func (conn *ClientConn) Start() error
func (*ClientConn) UseCryptoCodec ¶
func (conn *ClientConn) UseCryptoCodec(cryptoType CryptoType)
ClientConn
type ConnHandler ¶
type CryptCodec ¶
type CryptoKeys ¶
type CryptoKeys struct {
// contains filtered or unexported fields
}
type CryptoNonce ¶
type CryptoNonce struct {
// contains filtered or unexported fields
}
type CryptoType ¶
type CryptoType byte
const ( UseChacha20 CryptoType = 0x05 UseSalsa20 CryptoType = 0x06 )
type DataShards ¶
type DataShards struct {
// contains filtered or unexported fields
}
type FecCodecDecoder ¶
type FecCodecDecoder struct {
// contains filtered or unexported fields
}
func NewFecDecoder ¶
func NewFecDecoder(dataShards, parityShards, bufferSize int) *FecCodecDecoder
type FecCodecEncoder ¶
type FecCodecEncoder struct {
// contains filtered or unexported fields
}
func NewFecEncoder ¶
func NewFecEncoder(dataShards, parityShards, bufferSize int) *FecCodecEncoder
type Logger ¶
type Logger interface { Fatal(str string) Fatalf(format string, v ...interface{}) Error(str string) Errorf(format string, v ...interface{}) Warn(str string) Warnf(format string, v ...interface{}) Info(str string) Infof(format string, v ...interface{}) Debug(str string) Debugf(format string, v ...interface{}) }
type PlaintextData ¶
type PlaintextData []byte
func (PlaintextData) Data ¶
func (p PlaintextData) Data() []byte
func (PlaintextData) Type ¶
func (p PlaintextData) Type() ProtoType
type RawConn ¶
func (*RawConn) SetConnHandler ¶
func (conn *RawConn) SetConnHandler(handler ConnHandler)
func (*RawConn) SetUpdateInterval ¶
MUST invoke before start
func (*RawConn) StartKCPStatus ¶
func (conn *RawConn) StartKCPStatus()
For use KCP status: Need To inject Logger object into gouxp
func (*RawConn) StopKCPStatus ¶
func (conn *RawConn) StopKCPStatus()
type Salsa20Crypto ¶
type Salsa20Crypto struct {
// contains filtered or unexported fields
}
func NewSalsa20CryptoCodec ¶
func NewSalsa20CryptoCodec() *Salsa20Crypto
Salsa20 use 8 or 24bytes nonce, we choose 8bytes
func (*Salsa20Crypto) Decrypt ¶
func (codec *Salsa20Crypto) Decrypt(src []byte) (dst []byte, err error)
func (*Salsa20Crypto) Encrypt ¶
func (codec *Salsa20Crypto) Encrypt(src []byte) (dst []byte, err error)
func (*Salsa20Crypto) SetKey ¶
func (codec *Salsa20Crypto) SetKey(key []byte)
func (*Salsa20Crypto) SetReadNonce ¶
func (codec *Salsa20Crypto) SetReadNonce(nonce []byte)
func (*Salsa20Crypto) SetWriteNonce ¶
func (codec *Salsa20Crypto) SetWriteNonce(nonce []byte)
type Server ¶
func NewServer ¶
func NewServer(rwc net.PacketConn, handler ServerHandler, parallelCount uint32) *Server
func (*Server) UseCryptoCodec ¶
func (s *Server) UseCryptoCodec(cryptoType CryptoType)
type ServerConn ¶
type ServerConn struct { RawConn // contains filtered or unexported fields }
type ServerHandler ¶
type ServerHandler interface { OnNewConnComing(conn *ServerConn) OnConnClosed(conn *ServerConn, err error) OnClosed(err error) }
type TimerScheduler ¶
type TimerScheduler struct {
// contains filtered or unexported fields
}
func NewTimerScheduler ¶
func NewTimerScheduler(parallelCount uint32) *TimerScheduler
func (*TimerScheduler) Close ¶
func (ts *TimerScheduler) Close()
func (*TimerScheduler) PushTask ¶
func (ts *TimerScheduler) PushTask(exec func(), t uint32)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.