Documentation
¶
Index ¶
- Variables
- type CompressionModule
- type Decoder
- func (d *Decoder) Fetch() (transport.MsgPacket, error)
- func (d *Decoder) FetchFrom(buff *bytes.Buffer) (transport.MsgPacket, error)
- func (d *Decoder) GC()
- func (d *Decoder) GetCompressionModule() ICompressionModule
- func (d *Decoder) GetEncryptionModule() IEncryptionModule
- func (d *Decoder) GetMACModule() IMACModule
- func (d *Decoder) GetMsgCreator() IMsgCreator
- func (d *Decoder) ReadFrom(r io.Reader) (int64, error)
- func (d *Decoder) Reset()
- func (d *Decoder) Write(p []byte) (int, error)
- type Encoder
- func (e *Encoder) GetCompressedSize() int
- func (e *Encoder) GetCompressionModule() ICompressionModule
- func (e *Encoder) GetEncryption() bool
- func (e *Encoder) GetEncryptionModule() IEncryptionModule
- func (e *Encoder) GetMACModule() IMACModule
- func (e *Encoder) GetPatchMAC() bool
- func (e *Encoder) Read(p []byte) (int, error)
- func (e *Encoder) Reset()
- func (e *Encoder) Stuff(flags transport.Flags, msg transport.Msg) error
- func (e *Encoder) StuffTo(writer io.Writer, flags transport.Flags, msg transport.Msg) error
- func (e *Encoder) WriteTo(w io.Writer) (int64, error)
- type EncryptionModule
- type FetchNonce
- type ICompressionModule
- type IDecoder
- type IEncoder
- type IEncryptionModule
- type IMACModule
- type IMsgCreator
- type MAC32Module
- func (m *MAC32Module) GC()
- func (m *MAC32Module) PatchMAC(msgId transport.MsgId, flags transport.Flags, msgBuf []byte) (dst []byte, err error)
- func (m *MAC32Module) SizeofMAC(msgLen int) int
- func (m *MAC32Module) VerifyMAC(msgId transport.MsgId, flags transport.Flags, msgBuf []byte) (dst []byte, err error)
- type MAC64Module
- func (m *MAC64Module) GC()
- func (m *MAC64Module) PatchMAC(msgId transport.MsgId, flags transport.Flags, msgBuf []byte) (dst []byte, err error)
- func (m *MAC64Module) SizeofMAC(msgLen int) int
- func (m *MAC64Module) VerifyMAC(msgId transport.MsgId, flags transport.Flags, msgBuf []byte) (dst []byte, err error)
- type MACModule
- type MsgCreator
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrEmptyBuffer = errors.New("i/o empty buffer") // 缓存空 ErrMsgNotRegistered = errors.New("msg not registered") // 消息未注册 )
View Source
var BytesPool = bytespool.NewCapacityPools(32, math.MaxInt32)
BytesPool 字节对象池,用于减少GC提高编解码性能
View Source
var (
ErrIncorrectMAC = errors.New("incorrect MAC")
)
Functions ¶
This section is empty.
Types ¶
type CompressionModule ¶
type CompressionModule struct { CompressionStream method.CompressionStream // 压缩流 // contains filtered or unexported fields }
CompressionModule 压缩模块
func (*CompressionModule) Compress ¶
func (m *CompressionModule) Compress(src []byte) (dst []byte, compressed bool, err error)
Compress 压缩数据
func (*CompressionModule) Uncompress ¶
func (m *CompressionModule) Uncompress(src []byte) (dst []byte, err error)
Uncompress 解压缩数据
type Decoder ¶
type Decoder struct { MsgCreator IMsgCreator // 消息对象构建器 EncryptionModule IEncryptionModule // 加密模块 MACModule IMACModule // MAC模块 CompressionModule ICompressionModule // 压缩模块 // contains filtered or unexported fields }
Decoder 消息包解码器
func (*Decoder) GetCompressionModule ¶
func (d *Decoder) GetCompressionModule() ICompressionModule
GetCompressionModule 获取压缩模块
func (*Decoder) GetEncryptionModule ¶
func (d *Decoder) GetEncryptionModule() IEncryptionModule
GetEncryptionModule 获取加密模块
func (*Decoder) GetMsgCreator ¶
func (d *Decoder) GetMsgCreator() IMsgCreator
GetMsgCreator 获取消息对象构建器
type Encoder ¶
type Encoder struct { EncryptionModule IEncryptionModule // 加密模块 MACModule IMACModule // MAC模块 CompressionModule ICompressionModule // 压缩模块 Encryption bool // 开启加密 PatchMAC bool // 开启MAC CompressedSize int // 启用压缩阀值(字节),<=0表示不开启 // contains filtered or unexported fields }
Encoder 消息包编码器
func (*Encoder) GetCompressedSize ¶
GetCompressedSize 获取启用压缩阀值(字节),<=0表示不开启
func (*Encoder) GetCompressionModule ¶
func (e *Encoder) GetCompressionModule() ICompressionModule
GetCompressionModule 获取压缩模块
func (*Encoder) GetEncryptionModule ¶
func (e *Encoder) GetEncryptionModule() IEncryptionModule
GetEncryptionModule 获取加密模块
type EncryptionModule ¶
type EncryptionModule struct { CipherStream method.CipherStream // 密码流 Padding method.Padding // 填充方案 FetchNonce FetchNonce // 获取nonce值 // contains filtered or unexported fields }
EncryptionModule 加密模块
func (*EncryptionModule) SizeOfAddition ¶
func (m *EncryptionModule) SizeOfAddition(msgLen int) (int, error)
SizeOfAddition 附加数据大小
func (*EncryptionModule) Transforming ¶
func (m *EncryptionModule) Transforming(dst, src []byte) (ret []byte, err error)
Transforming 变换数据
type FetchNonce ¶
type ICompressionModule ¶
type ICompressionModule interface { // Compress 压缩数据 Compress(src []byte) (dst []byte, compressed bool, err error) // Uncompress 解压缩数据 Uncompress(src []byte) (dst []byte, err error) // GC GC GC() }
ICompressionModule 压缩模块接口
type IDecoder ¶
type IDecoder interface { io.Writer io.ReaderFrom // Reset 重置缓存 Reset() // Fetch 取出消息包 Fetch() (transport.MsgPacket, error) // FetchFrom 取出消息包 FetchFrom(buff *bytes.Buffer) (transport.MsgPacket, error) // GetMsgCreator 获取消息对象构建器 GetMsgCreator() IMsgCreator // GetEncryptionModule 获取加密模块 GetEncryptionModule() IEncryptionModule // GetMACModule 获取MAC模块 GetMACModule() IMACModule // GetCompressionModule 获取压缩模块 GetCompressionModule() ICompressionModule // GC GC GC() }
IDecoder 消息包解码器接口
type IEncoder ¶
type IEncoder interface { io.Reader io.WriterTo // Reset 重置缓存 Reset() // Stuff 填充消息 Stuff(flags transport.Flags, msg transport.Msg) error // StuffTo 填充消息 StuffTo(writer io.Writer, flags transport.Flags, msg transport.Msg) error // GetEncryptionModule 获取加密模块 GetEncryptionModule() IEncryptionModule // GetMACModule 获取MAC模块 GetMACModule() IMACModule // GetCompressionModule 获取压缩模块 GetCompressionModule() ICompressionModule // GetEncryption 获取开启加密 GetEncryption() bool // GetPatchMAC 获取开启MAC GetPatchMAC() bool // GetCompressedSize 获取启用压缩阀值(字节),<=0表示不开启 GetCompressedSize() int }
IEncoder 消息包编码器接口
type IEncryptionModule ¶
type IEncryptionModule interface { // Transforming 变换数据 Transforming(dst, src []byte) ([]byte, error) // SizeOfAddition 附加数据大小 SizeOfAddition(msgLen int) (int, error) // GC GC GC() }
IEncryptionModule 加密模块接口
type IMACModule ¶
type IMACModule interface { // PatchMAC 补充MAC PatchMAC(msgId transport.MsgId, flags transport.Flags, msgBuf []byte) (dst []byte, err error) // VerifyMAC 验证MAC VerifyMAC(msgId transport.MsgId, flags transport.Flags, msgBuf []byte) (dst []byte, err error) // SizeofMAC MAC大小 SizeofMAC(msgLen int) int // GC GC GC() }
IMACModule MAC模块接口
type IMsgCreator ¶
IMsgCreator 消息对象构建器接口
type MAC32Module ¶
type MAC32Module struct { Hash hash.Hash32 // hash(32bit)函数 PrivateKey []byte // 秘钥 // contains filtered or unexported fields }
MAC32Module MAC32模块
type MAC64Module ¶
type MAC64Module struct { Hash hash.Hash64 // hash(64bit)函数 PrivateKey []byte // 秘钥 // contains filtered or unexported fields }
MAC64Module MAC64模块
type MACModule ¶
type MACModule struct { Hash hash.Hash // hash函数 PrivateKey []byte // 秘钥 // contains filtered or unexported fields }
MACModule MAC模块
type MsgCreator ¶
type MsgCreator struct {
// contains filtered or unexported fields
}
MsgCreator 消息对象构建器
func (*MsgCreator) Deregister ¶
func (c *MsgCreator) Deregister(msgId transport.MsgId)
Deregister 取消注册消息
Click to show internal directories.
Click to hide internal directories.