codec

package
v0.96.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TRANSPORT_TCP  = 1 // TCP
	TRANSPORT_HTTP = 2 // HTTP
	TRANSPORT_UDP  = 3 // UDP, TODO(@benqi): 未发现有支持UDP的客户端
)

Transport类型,不支持UDP

View Source
const (

	// ABRIDGED_FLAG = 0xef
	ABRIDGED_FLAG = 0xef
	// ABRIDGED_INT32_FLAG = 0xfefefefe
	ABRIDGED_INT32_FLAG = 0xefefefef
	// INTERMEDIATE_FLAG = 0xcccccccc
	INTERMEDIATE_FLAG = 0xeeeeeeee
	// PADDED_INTERMEDIATE_FLAG = 0xbbbbbbbb
	PADDED_INTERMEDIATE_FLAG = 0xdddddddd
	UNKNOWN_FLAG             = 0x02010316
	PVRG_FLAG                = 0x47725650 // PVrG
	FULL_FLAG                = 0x00000000

	// PROXY_FLAG websocket flag
	PROXY_FLAG = 0xaaaaaaaa

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

)

Variables

This section is empty.

Functions

This section is empty.

Types

type AbridgedCodec

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

func NewMTProtoAbridgedCodec added in v0.86.0

func NewMTProtoAbridgedCodec(conn io.ReadWriteCloser) *AbridgedCodec

func (*AbridgedCodec) Close added in v0.86.0

func (c *AbridgedCodec) Close() error

func (*AbridgedCodec) Context added in v0.86.3

func (c *AbridgedCodec) Context() interface{}

func (*AbridgedCodec) Receive added in v0.86.0

func (c *AbridgedCodec) Receive() (interface{}, error)

func (*AbridgedCodec) Send added in v0.86.0

func (c *AbridgedCodec) Send(msg interface{}) error

type AesCTR128Stream added in v0.86.0

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

func NewAesCTR128Stream added in v0.86.0

func NewAesCTR128Stream(conn io.ReadWriteCloser, d, e *crypto.AesCTR128Encrypt) *AesCTR128Stream

func (*AesCTR128Stream) Close added in v0.86.0

func (s *AesCTR128Stream) Close() error

func (*AesCTR128Stream) Read added in v0.86.0

func (s *AesCTR128Stream) Read(p []byte) (int, error)

func (*AesCTR128Stream) Write added in v0.86.0

func (s *AesCTR128Stream) Write(p []byte) (int, error)

type FullCodec

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

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

If a payload (packet) needs to be transmitted from server to client or from client to server, it is encapsulated as follows: 4 length bytes are added at the front (to include the length, the sequence number, and CRC32; always divisible by 4) and 4 bytes with the packet sequence number within this TCP connection (the first packet sent is numbered 0, the next one 1, etc.), and 4 CRC32 bytes at the end (length, sequence number, and payload together).

func NewMTProtoFullCodec added in v0.86.0

func NewMTProtoFullCodec(conn io.ReadWriteCloser) *FullCodec

func (*FullCodec) Close added in v0.86.0

func (c *FullCodec) Close() error

func (*FullCodec) Context added in v0.86.3

func (c *FullCodec) Context() interface{}

func (*FullCodec) Receive added in v0.86.0

func (c *FullCodec) Receive() (interface{}, error)

func (*FullCodec) Send added in v0.86.0

func (c *FullCodec) Send(msg interface{}) error

type HttpProxyCodec

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

func NewMTProtoHttpProxyCodec added in v0.86.0

func NewMTProtoHttpProxyCodec(conn net.Conn) *HttpProxyCodec

func (*HttpProxyCodec) Close added in v0.86.0

func (c *HttpProxyCodec) Close() error

func (*HttpProxyCodec) Context added in v0.86.3

func (c *HttpProxyCodec) Context() interface{}

func (*HttpProxyCodec) Receive added in v0.86.0

func (c *HttpProxyCodec) Receive() (interface{}, error)

func (*HttpProxyCodec) Send added in v0.86.0

func (c *HttpProxyCodec) Send(msg interface{}) error

type IntermediateCodec

type IntermediateCodec struct {
	// 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 NewMTProtoIntermediateCodec added in v0.86.0

func NewMTProtoIntermediateCodec(conn io.ReadWriteCloser) *IntermediateCodec

func (*IntermediateCodec) Close added in v0.86.0

func (c *IntermediateCodec) Close() error

func (*IntermediateCodec) Context added in v0.86.3

func (c *IntermediateCodec) Context() interface{}

func (*IntermediateCodec) Receive added in v0.86.0

func (c *IntermediateCodec) Receive() (interface{}, error)

func (*IntermediateCodec) Send added in v0.86.0

func (c *IntermediateCodec) Send(msg interface{}) error

type MTProtoTransport added in v0.86.0

type MTProtoTransport struct {
}

MTProtoTransport //////////////////////////////////////////////////////////////////////////////////////////////////////////

func NewMTProtoTransport added in v0.86.0

func NewMTProtoTransport() *MTProtoTransport

func (*MTProtoTransport) NewCodec added in v0.86.0

func (m *MTProtoTransport) NewCodec(rw io.ReadWriter) (net2.Codec, error)

type ObfuscatedCodec

type ObfuscatedCodec struct {
	net2.Codec
	// contains filtered or unexported fields
}

func NewMTProtoObfuscatedCodec added in v0.86.0

func NewMTProtoObfuscatedCodec(conn io.ReadWriteCloser, d, e *crypto.AesCTR128Encrypt, protocolType uint32, dc int16) *ObfuscatedCodec

type PaddedIntermediateCodec

type PaddedIntermediateCodec struct {
	// 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 NewMTProtoPaddedIntermediateCodec added in v0.86.0

func NewMTProtoPaddedIntermediateCodec(conn io.ReadWriteCloser) *PaddedIntermediateCodec

func (*PaddedIntermediateCodec) Close added in v0.86.0

func (c *PaddedIntermediateCodec) Close() error

func (*PaddedIntermediateCodec) Context added in v0.86.3

func (c *PaddedIntermediateCodec) Context() interface{}

func (*PaddedIntermediateCodec) Receive added in v0.86.0

func (c *PaddedIntermediateCodec) Receive() (interface{}, error)

func (*PaddedIntermediateCodec) Send added in v0.86.0

func (c *PaddedIntermediateCodec) Send(msg interface{}) error

type TransportCodec added in v0.86.0

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

func (*TransportCodec) Close added in v0.86.0

func (c *TransportCodec) Close() error

func (*TransportCodec) Context added in v0.86.3

func (c *TransportCodec) Context() interface{}

func (*TransportCodec) Receive added in v0.86.0

func (c *TransportCodec) Receive() (interface{}, error)

func (*TransportCodec) Send added in v0.86.0

func (c *TransportCodec) Send(msg interface{}) error

Jump to

Keyboard shortcuts

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