codec

package
v0.85.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERROR                       = -1
	INVALID                     = 0
	WAIT_FIRST_PACKET           = 1
	WAIT_PACKET_LENGTH_1        = 2
	WAIT_PACKET_LENGTH_1_PACKET = 3
	WAIT_PACKET_LENGTH_3        = 4
	WAIT_PACKET_LENGTH_3_PACKET = 5
	WAIT_PACKET_LENGTH          = 6
	WAIT_PACKET                 = 7
)
View Source
const (
	// Tcp Transport
	ABRIDGED_FLAG            = 0xef
	ABRIDGED_INT32_FLAG      = 0xefefefef
	INTERMEDIATE_FLAG        = 0xeeeeeeee
	PADDED_INTERMEDIATE_FLAG = 0xdddddddd
	UNKNOWN_FLAG             = 0x02010316
	PVRG_FLAG                = 0x47725650 // PVrG
	FULL_FLAG                = 0x00000000

	// Http Transport
	HTTP_HEAD_FLAG   = 0x44414548 // HEAD
	HTTP_POST_FLAG   = 0x54534f50 // POST
	HTTP_GET_FLAG    = 0x20544547 // GET
	HTTP_OPTION_FLAG = 0x4954504f // OPTION

)
View Source
const (
	MAX_MTPRORO_FRAME_SIZE = 16777216
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AbridgedCodec

type AbridgedCodec struct {
	*AesCTR128Crypto
	// contains filtered or unexported fields
}

func (*AbridgedCodec) Clone

func (c *AbridgedCodec) Clone() gnet.ICodec

Clone ...

func (*AbridgedCodec) Decode

func (c *AbridgedCodec) Decode(conn gnet.Conn) (interface{}, error)

Decode decodes frames from TCP stream via specific implementation.

func (*AbridgedCodec) Encode

func (c *AbridgedCodec) Encode(conn gnet.Conn, msg interface{}) ([]byte, error)

Encode encodes frames upon server responses into TCP stream.

func (*AbridgedCodec) Release

func (c *AbridgedCodec) Release()

Release ...

type AesCTR128Crypto

type AesCTR128Crypto struct {
	// contains filtered or unexported fields
}

AesCTR128Crypto AesCTR128Crypto

func (*AesCTR128Crypto) Decrypt

func (e *AesCTR128Crypto) Decrypt(plaintext []byte) []byte

func (*AesCTR128Crypto) Encrypt

func (e *AesCTR128Crypto) Encrypt(plaintext []byte) []byte

type FullCodec

type FullCodec struct {
}

FullCodec FullCodec

func (*FullCodec) Clone

func (c *FullCodec) Clone() gnet.ICodec

Clone ...

func (*FullCodec) Decode

func (c *FullCodec) Decode(conn gnet.Conn) (interface{}, error)

Decode decodes frames from TCP stream via specific implementation.

func (*FullCodec) Encode

func (c *FullCodec) Encode(conn gnet.Conn, msg interface{}) ([]byte, error)

Encode encodes frames upon server responses into TCP stream.

func (*FullCodec) Release

func (c *FullCodec) Release()

Release ...

type HttpProxyCodec

type HttpProxyCodec struct {
	// contains filtered or unexported fields
}

func (*HttpProxyCodec) Clone

func (c *HttpProxyCodec) Clone() gnet.ICodec

Clone ...

func (*HttpProxyCodec) Decode

func (c *HttpProxyCodec) Decode(conn gnet.Conn) (interface{}, error)

Decode decodes frames from TCP stream via specific implementation.

func (*HttpProxyCodec) Encode

func (c *HttpProxyCodec) Encode(conn gnet.Conn, msg interface{}) ([]byte, error)

Encode encodes frames upon server responses into TCP stream.

func (*HttpProxyCodec) Release

func (c *HttpProxyCodec) Release()

Release ...

type IntermediateCodec

type IntermediateCodec struct {
	*AesCTR128Crypto
	// contains filtered or unexported fields
}

IntermediateCodec https://core.telegram.org/mtproto#tcp-transport

In case 4-byte data alignment is needed, an intermediate version of the original protocol may be used: if the client sends 0xeeeeeeee as the first int (four bytes), then packet length is encoded always by four bytes as in the original version, but the sequence number and CRC32 are omitted, thus decreasing total packet size by 8 bytes.

func (*IntermediateCodec) Clone

func (c *IntermediateCodec) Clone() gnet.ICodec

Clone ...

func (*IntermediateCodec) Decode

func (c *IntermediateCodec) Decode(conn gnet.Conn) (interface{}, error)

Decode decodes frames from TCP stream via specific implementation.

func (*IntermediateCodec) Encode

func (c *IntermediateCodec) Encode(conn gnet.Conn, msg interface{}) ([]byte, error)

Encode encodes frames upon server responses into TCP stream.

func (*IntermediateCodec) Release

func (c *IntermediateCodec) Release()

Release ...

type MTPRawMessage

type MTPRawMessage struct {
	IsHttp     bool
	AuthKeyId  int64  // 由原始数据解压获得
	QuickAckId int32  // EncryptedMessage,则可能存在
	Payload    []byte // 原始数据
}

MTPRawMessage MTPRawMessage

func NewMTPRawMessage

func NewMTPRawMessage(isHttp bool, authKeyId int64, quickAckId int32, payload []byte) *MTPRawMessage

func (*MTPRawMessage) GetAuthKeyId

func (m *MTPRawMessage) GetAuthKeyId() int64

func (*MTPRawMessage) GetIsHttp

func (m *MTPRawMessage) GetIsHttp() bool

func (*MTPRawMessage) GetQuickAckId

func (m *MTPRawMessage) GetQuickAckId() int32

func (*MTPRawMessage) String

func (m *MTPRawMessage) String() string

type MTProtoCodec

type MTProtoCodec struct {
	// contains filtered or unexported fields
}

///////////////////////////////////////////////////////////////////////////////////////////////////

func NewMTProtoCodec

func NewMTProtoCodec() *MTProtoCodec

func (*MTProtoCodec) Clone

func (c *MTProtoCodec) Clone() gnet.ICodec

Clone ...

func (*MTProtoCodec) Decode

func (c *MTProtoCodec) Decode(conn gnet.Conn) (interface{}, error)

Decode decodes frames from TCP stream via specific implementation.

func (*MTProtoCodec) Encode

func (c *MTProtoCodec) Encode(conn gnet.Conn, msg interface{}) ([]byte, error)

Encode encodes frames upon server responses into TCP stream.

func (*MTProtoCodec) Release

func (c *MTProtoCodec) Release()

Release ...

type ObfuscatedCodec

type ObfuscatedCodec struct {
	gnet.ICodec
	// contains filtered or unexported fields
}

type PaddedIntermediateCodec

type PaddedIntermediateCodec struct {
	*AesCTR128Crypto
	// contains filtered or unexported fields
}

PaddedIntermediateCodec https://core.telegram.org/mtproto#tcp-transport

In case 4-byte data alignment is needed, an intermediate version of the original protocol may be used: if the client sends 0xeeeeeeee as the first int (four bytes), then packet length is encoded always by four bytes as in the original version, but the sequence number and CRC32 are omitted, thus decreasing total packet size by 8 bytes.

func (*PaddedIntermediateCodec) Clone

func (c *PaddedIntermediateCodec) Clone() gnet.ICodec

Clone ...

func (*PaddedIntermediateCodec) Decode

func (c *PaddedIntermediateCodec) Decode(conn gnet.Conn) (interface{}, error)

Decode decodes frames from TCP stream via specific implementation.

func (*PaddedIntermediateCodec) Encode

func (c *PaddedIntermediateCodec) Encode(conn gnet.Conn, msg interface{}) ([]byte, error)

Encode encodes frames upon server responses into TCP stream.

func (*PaddedIntermediateCodec) Release

func (c *PaddedIntermediateCodec) Release()

Release ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL