package proto
Import Path
github.com/gotd/td/internal/proto (on go.dev)
Dependency Relation
imports 10 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)
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
func github.com/gotd/td/internal/mtproto.(*Conn).processContainerMessage(msgID int64, msg Message) error
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
MessageID : context.stringer
MessageID : runtime.stringer
func NewMessageID(now time.Time, typ MessageType) MessageID
func NewMessageIDNano(nano int64, typ MessageType) MessageID
MessageIDBuf stores last N message ids and is used in replay attack mitigation.
buf []int64
mux sync.Mutex
Consume returns false if message should be discarded.
*MessageIDBuf : github.com/gotd/td/internal/mtproto.MessageBuf
func NewMessageIDBuf(n int) *MessageIDBuf
MessageIDGen is message id generator that provides collision prevention.
The main reason of such structure is that now() can return same time during
multiple calls and that leads to duplicate message id.
mux sync.Mutex
nano int64
now func() time.Time
New generates new message id for provided type, protecting from collisions
that are caused by low system time resolution.
*MessageIDGen : github.com/gotd/td/internal/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
MessageType : context.stringer
MessageType : runtime.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/internal/mtproto.MessageIDSource.New(t MessageType) int64
func github.com/gotd/td/internal/exchange.Exchanger.unencryptedWriter(input, output MessageType) exchange.unencryptedWriter
const MessageFromClient
const MessageFromServer
const MessageServerResponse
const MessageUnknown
Package-Level Functions (total 7, 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.
This generator compensates time resolution problem removing
probability of id collision.
Such problem can be observed for relatively high RPS, sequential calls to
time.Now() will return same time which leads to equal ids.
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 11, 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.
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |