package proto

Import Path
	github.com/gotd/td/proto (on go.dev)

Dependency Relation
	imports 11 packages, and imported by 3 packages

Involved Source Files container.go Package proto implements MTProto 2.0 primitives. See https://core.telegram.org/mtproto/description for reference. gzip.go message_id.go registry.go rpc_result.go unencrypted_message.go
Package-Level Type Names (total 12, in which 10 are exported)
/* sort exporteds by: | */
DecompressionBombErr means that GZIP decode detected decompression bomb which decompressed payload is significantly higher than initial compressed size and stopped decompression to prevent OOM. Compressed int Decompressed int (*DecompressionBombErr) Error() string *DecompressionBombErr : error
GZIP represents a Packed Object. Used to replace any other object (or rather, a serialization thereof) with its archived (gzipped) representation. Data []byte Decode implements bin.Decoder. Encode implements bin.Encoder. *GZIP : github.com/gotd/td/bin.Decoder GZIP : github.com/gotd/td/bin.Encoder *GZIP : github.com/gotd/td/bin.Object
Message is element of MessageContainer. Body []byte Bytes int ID int64 SeqNo int Decode implements bin.Decoder. Encode implements bin.Encoder. *Message : github.com/gotd/td/bin.Decoder *Message : github.com/gotd/td/bin.Encoder *Message : github.com/gotd/td/bin.Object
MessageContainer contains slice of messages. Messages []Message Decode implements bin.Decoder. Encode implements bin.Decoder. *MessageContainer : github.com/gotd/td/bin.Decoder *MessageContainer : github.com/gotd/td/bin.Encoder *MessageContainer : github.com/gotd/td/bin.Object
MessageID represents 64-bit message id. ( MessageID) String() string Time returns approximate time when MessageID were generated. Type returns message type. MessageID : fmt.Stringer func NewMessageID(now time.Time, typ MessageType) MessageID func NewMessageIDNano(nano int64, typ MessageType) MessageID
MessageIDBuf stores the last N received message ids and is used in replay attack mitigation. It works like TDLib's MessageIdDuplicateChecker: ids are kept sorted in a buffer of 2N, so an id is checked by binary search, an increasing id (the common case) is appended, and the oldest N are dropped at once when the buffer is full. Consume returns false if message should be discarded. Reset forgets all stored message ids, e.g. when a new session is started. *MessageIDBuf : github.com/gotd/td/mtproto.MessageBuf func NewMessageIDBuf(n int) *MessageIDBuf
MessageIDGen is message id generator that provides collision prevention. Ids follow TDLib (AuthData::next_message_id): the time of now() with 22 random bits XORed into the fraction, and if that is not above the last id (now() returned the same or an earlier time, e.g. after a correction of the server time offset), the last id plus a random multiple of 4. So ids always increase, and their lower bits don't reveal the clock resolution. New generates new message id for provided type, protecting from collisions that are caused by low system time resolution. Reset forgets the last generated id, so the next ids follow the current time again even if earlier ones were higher, e.g. generated before the server time offset was corrected. Ids must keep increasing within a server session, so Reset is for a new session only. *MessageIDGen : github.com/gotd/td/mtproto.MessageIDSource func NewMessageIDGen(now func() time.Time) *MessageIDGen
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. ( MessageType) String() string MessageType : fmt.Stringer func MessageID.Type() MessageType func NewMessageID(now time.Time, typ MessageType) MessageID func NewMessageIDNano(nano int64, typ MessageType) MessageID func (*MessageIDGen).New(t MessageType) int64 func github.com/gotd/td/mtproto.MessageIDSource.New(t MessageType) int64 const MessageFromClient const MessageFromServer const MessageServerResponse const MessageUnknown
Result is rpc_result#f35c6d01. RequestMessageID int64 Result []byte Decode implements bin.Decoder. Encode implements bin.Encoder. *Result : github.com/gotd/td/bin.Decoder *Result : github.com/gotd/td/bin.Encoder *Result : github.com/gotd/td/bin.Object
UnencryptedMessage is plaintext message. MessageData []byte MessageID int64 Decode implements bin.Decoder. Encode implements bin.Encoder. *UnencryptedMessage : github.com/gotd/td/bin.Decoder UnencryptedMessage : github.com/gotd/td/bin.Encoder *UnencryptedMessage : github.com/gotd/td/bin.Object
Package-Level Functions (total 9, in which 5 are exported)
NewMessageID returns new message id for provided time and type.
NewMessageIDBuf initializes new message id buffer for last N stored values.
NewMessageIDGen creates new message id generator. Current time will be provided by now() function, e.g. the server time of mtproto.ServerTime.
NewMessageIDNano returns new message id for provided current unix nanoseconds and type.
TypesMap returns mapping from type ids to TL type names.
Package-Level Variables (total 2, neither is exported)
Package-Level Constants (total 12, in which 7 are exported)
GZIPTypeID is TL type id of GZIP.
MessageContainerTypeID is TL type id of MessageContainer.
MessageFromClient is client message identifiers.
MessageFromServer is a message from the server.
MessageServerResponse is a response to a client message.
MessageUnknown reports that message id has unknown time and probably should be ignored.
ResultTypeID is TL type id of Result.