Documentation ¶
Overview ¶
Package codec contains MTProto transport encoding implementations.
Index ¶
- Constants
- Variables
- type Abridged
- type Codec
- type Full
- type Intermediate
- type NoHeader
- type PaddedIntermediate
- func (i PaddedIntermediate) ObfuscatedTag() [4]byte
- func (i PaddedIntermediate) Read(r io.Reader, b *bin.Buffer) error
- func (i PaddedIntermediate) ReadHeader(r io.Reader) error
- func (i PaddedIntermediate) Write(w io.Writer, b *bin.Buffer) error
- func (i PaddedIntermediate) WriteHeader(w io.Writer) error
- type ProtocolErr
- type TaggedCodec
Constants ¶
const ( // CodeAuthKeyNotFound means that specified auth key ID cannot be found by the DC. // Also, may be returned during key exchange. CodeAuthKeyNotFound = 404 // CodeWrongDC means that current DC is wrong. // Usually returned by server when key exchange sends wrong DC ID. CodeWrongDC = 444 // CodeTransportFlood means that too many transport connections are // established to the same IP in a too short lapse of time, or if any // of the container/service message limits are reached. CodeTransportFlood = 429 )
Variables ¶
var AbridgedClientStart = [1]byte{0xef}
AbridgedClientStart is starting bytes sent by client in Abridged mode.
Note that server does not respond with it.
var ErrProtocolHeaderMismatch = errors.New("protocol header mismatch")
ErrProtocolHeaderMismatch means that received protocol header is mismatched with expected.
var IntermediateClientStart = [4]byte{0xee, 0xee, 0xee, 0xee}
IntermediateClientStart is starting bytes sent by client in Intermediate mode.
Note that server does not respond with it.
var PaddedIntermediateClientStart = [4]byte{0xdd, 0xdd, 0xdd, 0xdd}
PaddedIntermediateClientStart is starting bytes sent by client in Padded intermediate mode.
Note that server does not respond with it.
Functions ¶
This section is empty.
Types ¶
type Abridged ¶ added in v0.14.0
type Abridged struct{}
Abridged is intermediate MTProto transport.
See https://core.telegram.org/mtproto/mtproto-transports#abridged
func (Abridged) ObfuscatedTag ¶ added in v0.14.0
ObfuscatedTag returns protocol tag for obfuscation.
func (Abridged) ReadHeader ¶ added in v0.14.0
ReadHeader reads protocol tag.
type Codec ¶ added in v0.14.0
type Codec interface { // WriteHeader sends protocol tag if needed. WriteHeader(w io.Writer) error // ReadHeader reads protocol tag if needed. ReadHeader(r io.Reader) error // Write encode to writer message from given buffer. Write(w io.Writer, b *bin.Buffer) error // Read fills buffer with received message. Read(r io.Reader, b *bin.Buffer) error }
Codec is MTProto transport protocol encoding abstraction.
type Full ¶
type Full struct {
// contains filtered or unexported fields
}
Full is full MTProto transport.
See https://core.telegram.org/mtproto/mtproto-transports#full
func (*Full) ReadHeader ¶
ReadHeader reads protocol tag.
type Intermediate ¶
type Intermediate struct{}
Intermediate is intermediate MTProto transport.
See https://core.telegram.org/mtproto/mtproto-transports#intermediate
func (Intermediate) ObfuscatedTag ¶ added in v0.14.0
func (i Intermediate) ObfuscatedTag() [4]byte
ObfuscatedTag returns protocol tag for obfuscation.
func (Intermediate) ReadHeader ¶
func (i Intermediate) ReadHeader(r io.Reader) (err error)
ReadHeader reads protocol tag.
func (Intermediate) WriteHeader ¶
func (i Intermediate) WriteHeader(w io.Writer) (err error)
WriteHeader sends protocol tag.
type NoHeader ¶ added in v0.21.1
type NoHeader struct {
Codec
}
NoHeader wraps codec to skip WriteHeader.
func (NoHeader) ReadHeader ¶ added in v0.21.1
ReadHeader implements Codec.
type PaddedIntermediate ¶ added in v0.14.0
type PaddedIntermediate struct{}
PaddedIntermediate is intermediate MTProto transport.
See https://core.telegram.org/mtproto/mtproto-transports#padded-intermediate
func (PaddedIntermediate) ObfuscatedTag ¶ added in v0.14.0
func (i PaddedIntermediate) ObfuscatedTag() [4]byte
ObfuscatedTag returns protocol tag for obfuscation.
func (PaddedIntermediate) ReadHeader ¶ added in v0.14.0
func (i PaddedIntermediate) ReadHeader(r io.Reader) error
ReadHeader reads protocol tag.
func (PaddedIntermediate) Write ¶ added in v0.14.0
Write encode to writer message from given buffer.
func (PaddedIntermediate) WriteHeader ¶ added in v0.14.0
func (i PaddedIntermediate) WriteHeader(w io.Writer) error
WriteHeader sends protocol tag.
type ProtocolErr ¶
type ProtocolErr struct {
Code int32
}
ProtocolErr represents protocol level error.
func (ProtocolErr) Error ¶
func (p ProtocolErr) Error() string
type TaggedCodec ¶ added in v0.14.0
type TaggedCodec interface { Codec // ObfuscatedTag returns protocol tag for obfuscation. ObfuscatedTag() [4]byte }
TaggedCodec is codec with protocol tag.