proto

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Proto implements MTProto 2.0 primitives.

See https://core.telegram.org/mtproto/description for reference.

Index

Constants

View Source
const (
	// CodeAuthKeyNotFound means that specified auth key ID cannot be found by the DC.
	CodeAuthKeyNotFound = 404

	// 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
)
View Source
const GZIPTypeID = 0x3072cfa1
View Source
const Layer = 121

Layer is current compatible layer.

View Source
const MessageContainerTypeID = 0x73f1f8dc
View Source
const ResultTypeID = 0xf35c6d01

Variables

View Source
var ErrMessageTooBig = errors.New("message is too big")

ErrMessageTooBig means that message length is too big to be handled.

View Source
var IntermediateClientStart = []byte{0xee, 0xee, 0xee, 0xee}

IntermediateClientStart is starting bytes sent by client in Intermediate mode.

Note that server does not respond with it.

Functions

func ReadIntermediate

func ReadIntermediate(r io.Reader, b *bin.Buffer) error

ReadIntermediate reads payload from r to b.

func TypesMap

func TypesMap() map[uint32]string

Types returns mapping from type ids to TL type names.

func WriteIntermediate

func WriteIntermediate(w io.Writer, b *bin.Buffer) error

EncodeIntermediate encodes b as payload to w.

Types

type GZIP

type GZIP struct {
	Data []byte
}

GZIP represents a Packed Object.

Used to replace any other object (or rather, a serialization thereof) with its archived (gzipped) representation.

func (*GZIP) Decode

func (g *GZIP) Decode(b *bin.Buffer) error

type GetConfig

type GetConfig struct{}

func (GetConfig) Encode

func (g GetConfig) Encode(b *bin.Buffer) error

type InitConnection

type InitConnection struct {
	Flags          bin.Fields
	ID             int
	DeviceModel    string
	SystemVersion  string
	AppVersion     string
	SystemLangCode string
	LangPack       string
	LangCode       string

	Query bin.Encoder
}

func (InitConnection) Encode

func (i InitConnection) Encode(b *bin.Buffer) error

type InvokeWithLayer

type InvokeWithLayer struct {
	Layer int
	Query bin.Encoder
}

func (InvokeWithLayer) Encode

func (i InvokeWithLayer) Encode(b *bin.Buffer) error

type Message

type Message struct {
	ID    int64
	SeqNo int
	Bytes int
	Body  []byte
}

func (*Message) Decode

func (m *Message) Decode(b *bin.Buffer) error

type MessageContainer

type MessageContainer struct {
	Messages []Message
}

func (*MessageContainer) Decode

func (m *MessageContainer) Decode(b *bin.Buffer) error

type MessageID

type MessageID int64

MessageID represents 64-bit message id.

func NewMessageID

func NewMessageID(now time.Time, typ MessageType) MessageID

NewMessageID returns new message id for provided time and type.

func (MessageID) Time

func (id MessageID) Time() time.Time

Time returns approximate time when MessageID were generated.

func (MessageID) Type

func (id MessageID) Type() MessageType

Type returns message type.

type MessageType

type MessageType byte

MessageType is type of message determined by message id.

A message is rejected over 300 seconds after it is created or 30 seconds before it is created (this is needed to protect from replay attacks).

The identifier of a message container must be strictly greater than those of its nested messages.

const (
	// MessageUnknown reports that message id has unknown time and probably
	// should be ignored.
	MessageUnknown MessageType = iota
	// MessageFromClient is client message identifiers.
	MessageFromClient
	// MessageServerResponse is a response to a client message.
	MessageServerResponse
	// MessageFromServer is a message from the server.
	MessageFromServer
)

type Result

type Result struct {
	RequestMessageID int64
	Result           []byte
}

func (*Result) Decode

func (r *Result) Decode(b *bin.Buffer) error

type UnencryptedMessage

type UnencryptedMessage struct {
	MessageID   int64
	MessageData []byte
}

UnencryptedMessage is plaintext message.

func (*UnencryptedMessage) Decode

func (u *UnencryptedMessage) Decode(b *bin.Buffer) error

func (UnencryptedMessage) Encode

func (u UnencryptedMessage) Encode(b *bin.Buffer) error

Jump to

Keyboard shortcuts

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