Documentation ¶
Index ¶
- Variables
- type CompressionModule
- type Decoder
- type DecoderCreator
- func (dc DecoderCreator) SetupCompressionModule(compressionModule ICompressionModule) DecoderCreator
- func (dc DecoderCreator) SetupEncryptionModule(encryptionModule IEncryptionModule) DecoderCreator
- func (dc DecoderCreator) SetupMACModule(macModule IMACModule) DecoderCreator
- func (dc DecoderCreator) Spawn() IDecoder
- type Encoder
- type EncoderCreator
- func (ec EncoderCreator) SetupCompressionModule(compressionModule ICompressionModule, compressedSize int) EncoderCreator
- func (ec EncoderCreator) SetupEncryptionModule(encryptionModule IEncryptionModule) EncoderCreator
- func (ec EncoderCreator) SetupMACModule(macModule IMACModule) EncoderCreator
- func (ec EncoderCreator) Spawn() IEncoder
- type EncryptionModule
- type FetchNonce
- type ICompressionModule
- type IDecoder
- type IEncoder
- type IEncryptionModule
- type IMACModule
- type IValidate
- type MAC32Module
- type MAC64Module
- type MACModule
Constants ¶
This section is empty.
Variables ¶
var (
ErrIncorrectMAC = errors.New("gtp: incorrect MAC") // MAC值不正确
)
Functions ¶
This section is empty.
Types ¶
type CompressionModule ¶
type CompressionModule struct {
CompressionStream method.CompressionStream // 压缩流
}
CompressionModule 压缩模块
func (*CompressionModule) Compress ¶
func (m *CompressionModule) Compress(src []byte) (dst binaryutil.RecycleBytes, compressed bool, err error)
Compress 压缩数据
func (*CompressionModule) Uncompress ¶
func (m *CompressionModule) Uncompress(src []byte) (dst binaryutil.RecycleBytes, err error)
Uncompress 解压缩数据
type Decoder ¶
type Decoder struct { MsgCreator gtp.IMsgCreator // 消息对象构建器 EncryptionModule IEncryptionModule // 加密模块 MACModule IMACModule // MAC模块 CompressionModule ICompressionModule // 压缩模块 // contains filtered or unexported fields }
Decoder 消息包解码器
type DecoderCreator ¶
type DecoderCreator struct {
// contains filtered or unexported fields
}
DecoderCreator 消息包解码器构建器
func CreateDecoder ¶
func CreateDecoder(msgCreator gtp.IMsgCreator) DecoderCreator
CreateDecoder 创建消息包解码器
func (DecoderCreator) SetupCompressionModule ¶
func (dc DecoderCreator) SetupCompressionModule(compressionModule ICompressionModule) DecoderCreator
SetupCompressionModule 安装压缩模块
func (DecoderCreator) SetupEncryptionModule ¶
func (dc DecoderCreator) SetupEncryptionModule(encryptionModule IEncryptionModule) DecoderCreator
SetupEncryptionModule 安装加密模块
func (DecoderCreator) SetupMACModule ¶
func (dc DecoderCreator) SetupMACModule(macModule IMACModule) DecoderCreator
SetupMACModule 安装MAC模块
type Encoder ¶
type Encoder struct { EncryptionModule IEncryptionModule // 加密模块 MACModule IMACModule // MAC模块 CompressionModule ICompressionModule // 压缩模块 Encryption bool // 开启加密 PatchMAC bool // 开启MAC CompressedSize int // 启用压缩阀值(字节),<=0表示不开启 }
Encoder 消息包编码器
func (*Encoder) Encode ¶
func (e *Encoder) Encode(flags gtp.Flags, msg gtp.MsgReader) (ret binaryutil.RecycleBytes, err error)
Encode 编码消息包
type EncoderCreator ¶
type EncoderCreator struct {
// contains filtered or unexported fields
}
EncoderCreator 消息包编码器构建器
func (EncoderCreator) SetupCompressionModule ¶
func (ec EncoderCreator) SetupCompressionModule(compressionModule ICompressionModule, compressedSize int) EncoderCreator
SetupCompressionModule 安装压缩模块
func (EncoderCreator) SetupEncryptionModule ¶
func (ec EncoderCreator) SetupEncryptionModule(encryptionModule IEncryptionModule) EncoderCreator
SetupEncryptionModule 安装加密模块
func (EncoderCreator) SetupMACModule ¶
func (ec EncoderCreator) SetupMACModule(macModule IMACModule) EncoderCreator
SetupMACModule 安装MAC模块
type EncryptionModule ¶
type EncryptionModule struct { Cipher method.Cipher // 对称密码算法 Padding method.Padding // 填充方案 FetchNonce FetchNonce // 获取nonce值 }
EncryptionModule 加密模块
func (*EncryptionModule) SizeOfAddition ¶
func (m *EncryptionModule) SizeOfAddition(msgLen int) (int, error)
SizeOfAddition 附加数据大小
func (*EncryptionModule) Transforming ¶
func (m *EncryptionModule) Transforming(dst, src []byte) (ret binaryutil.RecycleBytes, err error)
Transforming 变换数据
type ICompressionModule ¶
type ICompressionModule interface { // Compress 压缩数据 Compress(src []byte) (dst binaryutil.RecycleBytes, compressed bool, err error) // Uncompress 解压缩数据 Uncompress(src []byte) (dst binaryutil.RecycleBytes, err error) }
ICompressionModule 压缩模块接口
func NewCompressionModule ¶
func NewCompressionModule(cs method.CompressionStream) ICompressionModule
NewCompressionModule 创建压缩模块
type IDecoder ¶
type IDecoder interface { // Decode 解码消息包 Decode(data []byte, validate ...IValidate) (gtp.MsgPacket, int, error) // GC GC GC() }
IDecoder 消息包解码器接口
type IEncoder ¶
type IEncoder interface { // Encode 编码消息包 Encode(flags gtp.Flags, msg gtp.MsgReader) (binaryutil.RecycleBytes, error) }
IEncoder 消息包编码器接口
type IEncryptionModule ¶
type IEncryptionModule interface { // Transforming 变换数据 Transforming(dst, src []byte) (binaryutil.RecycleBytes, error) // SizeOfAddition 附加数据大小 SizeOfAddition(msgLen int) (int, error) }
IEncryptionModule 加密模块接口
func NewEncryptionModule ¶
func NewEncryptionModule(cipher method.Cipher, padding method.Padding, fetchNonce FetchNonce) IEncryptionModule
NewEncryptionModule 创建加密模块
type IMACModule ¶
type IMACModule interface { // PatchMAC 补充MAC PatchMAC(msgId gtp.MsgId, flags gtp.Flags, msgBuf []byte) (dst binaryutil.RecycleBytes, err error) // VerifyMAC 验证MAC VerifyMAC(msgId gtp.MsgId, flags gtp.Flags, msgBuf []byte) (dst []byte, err error) // SizeofMAC MAC大小 SizeofMAC(msgLen int) int }
IMACModule MAC模块接口
func NewMAC32Module ¶
func NewMAC32Module(h hash.Hash32, pk []byte) IMACModule
NewMAC32Module 创建MAC32模块
func NewMAC64Module ¶
func NewMAC64Module(h hash.Hash64, pk []byte) IMACModule
NewMAC64Module 创建MAC64模块
type MAC32Module ¶
MAC32Module MAC32模块
func (*MAC32Module) PatchMAC ¶
func (m *MAC32Module) PatchMAC(msgId gtp.MsgId, flags gtp.Flags, msgBuf []byte) (dst binaryutil.RecycleBytes, err error)
PatchMAC 补充MAC
type MAC64Module ¶
MAC64Module MAC64模块
func (*MAC64Module) PatchMAC ¶
func (m *MAC64Module) PatchMAC(msgId gtp.MsgId, flags gtp.Flags, msgBuf []byte) (dst binaryutil.RecycleBytes, err error)
PatchMAC 补充MAC