Documentation ¶
Overview ¶
Package proto implements MTProto 2.0 primitives.
See https://core.telegram.org/mtproto/description for reference.
Index ¶
- Constants
- func TypesMap() map[uint32]string
- type FutureSalt
- func (f *FutureSalt) Decode(b *bin.Buffer) error
- func (f *FutureSalt) Encode(b *bin.Buffer) error
- func (f *FutureSalt) FillFrom(from interface{ ... })
- func (f *FutureSalt) GetSalt() (value int64)
- func (f *FutureSalt) GetValidSince() (value int)
- func (f *FutureSalt) GetValidUntil() (value int)
- func (f *FutureSalt) String() string
- func (*FutureSalt) TypeID() uint32
- func (f *FutureSalt) TypeInfo() tdp.Type
- func (*FutureSalt) TypeName() string
- type FutureSalts
- func (f *FutureSalts) Decode(b *bin.Buffer) error
- func (f *FutureSalts) Encode(b *bin.Buffer) error
- func (f *FutureSalts) FillFrom(from interface{ ... })
- func (f *FutureSalts) GetNow() (value int)
- func (f *FutureSalts) GetReqMsgID() (value int64)
- func (f *FutureSalts) GetSalts() (value []FutureSalt)
- func (f *FutureSalts) String() string
- func (*FutureSalts) TypeID() uint32
- func (f *FutureSalts) TypeInfo() tdp.Type
- func (*FutureSalts) TypeName() string
- type GZIP
- type Message
- type MessageContainer
- type MessageID
- type MessageIDBuf
- type MessageIDGen
- type MessageType
- type Result
- type UnencryptedMessage
Constants ¶
const FutureSaltTypeID = 0x949d9dc
FutureSaltTypeID is TL type id of FutureSalt.
const FutureSaltsTypeID = 0xae500895
FutureSaltsTypeID is TL type id of FutureSalts.
const GZIPTypeID = 0x3072cfa1
GZIPTypeID is TL type id of GZIP.
const MessageContainerTypeID = 0x73f1f8dc
MessageContainerTypeID is TL type id of MessageContainer.
const ResultTypeID = 0xf35c6d01
ResultTypeID is TL type id of Result.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FutureSalt ¶ added in v0.28.0
type FutureSalt struct { // ValidSince field of FutureSalt. ValidSince int // ValidUntil field of FutureSalt. ValidUntil int // Salt field of FutureSalt. Salt int64 }
FutureSalt represents TL type `future_salt#949d9dc`.
func (*FutureSalt) Decode ¶ added in v0.28.0
func (f *FutureSalt) Decode(b *bin.Buffer) error
Decode implements bin.Decoder.
func (*FutureSalt) Encode ¶ added in v0.28.0
func (f *FutureSalt) Encode(b *bin.Buffer) error
Encode implements bin.Encoder.
func (*FutureSalt) FillFrom ¶ added in v0.28.0
func (f *FutureSalt) FillFrom(from interface { GetValidSince() (value int) GetValidUntil() (value int) GetSalt() (value int64) })
FillFrom fills FutureSalt from given interface.
func (*FutureSalt) GetSalt ¶ added in v0.28.0
func (f *FutureSalt) GetSalt() (value int64)
GetSalt returns value of Salt field.
func (*FutureSalt) GetValidSince ¶ added in v0.28.0
func (f *FutureSalt) GetValidSince() (value int)
GetValidSince returns value of ValidSince field.
func (*FutureSalt) GetValidUntil ¶ added in v0.28.0
func (f *FutureSalt) GetValidUntil() (value int)
GetValidUntil returns value of ValidUntil field.
func (*FutureSalt) String ¶ added in v0.28.0
func (f *FutureSalt) String() string
String implements fmt.Stringer.
func (*FutureSalt) TypeID ¶ added in v0.28.0
func (*FutureSalt) TypeID() uint32
TypeID returns type id in TL schema.
func (*FutureSalt) TypeInfo ¶ added in v0.28.0
func (f *FutureSalt) TypeInfo() tdp.Type
TypeInfo returns info about TL type.
func (*FutureSalt) TypeName ¶ added in v0.28.0
func (*FutureSalt) TypeName() string
TypeName returns name of type in TL schema.
type FutureSalts ¶ added in v0.28.0
type FutureSalts struct { // ReqMsgID field of FutureSalts. ReqMsgID int64 // Now field of FutureSalts. Now int // Salts field of FutureSalts. Salts []FutureSalt }
FutureSalts represents TL type `future_salts#ae500895`.
func (*FutureSalts) Decode ¶ added in v0.28.0
func (f *FutureSalts) Decode(b *bin.Buffer) error
Decode implements bin.Decoder.
func (*FutureSalts) Encode ¶ added in v0.28.0
func (f *FutureSalts) Encode(b *bin.Buffer) error
Encode implements bin.Encoder.
func (*FutureSalts) FillFrom ¶ added in v0.28.0
func (f *FutureSalts) FillFrom(from interface { GetReqMsgID() (value int64) GetNow() (value int) GetSalts() (value []FutureSalt) })
FillFrom fills FutureSalts from given interface.
func (*FutureSalts) GetNow ¶ added in v0.28.0
func (f *FutureSalts) GetNow() (value int)
GetNow returns value of Now field.
func (*FutureSalts) GetReqMsgID ¶ added in v0.28.0
func (f *FutureSalts) GetReqMsgID() (value int64)
GetReqMsgID returns value of ReqMsgID field.
func (*FutureSalts) GetSalts ¶ added in v0.28.0
func (f *FutureSalts) GetSalts() (value []FutureSalt)
GetSalts returns value of Salts field.
func (*FutureSalts) String ¶ added in v0.28.0
func (f *FutureSalts) String() string
String implements fmt.Stringer.
func (*FutureSalts) TypeID ¶ added in v0.28.0
func (*FutureSalts) TypeID() uint32
TypeID returns type id in TL schema.
func (*FutureSalts) TypeInfo ¶ added in v0.28.0
func (f *FutureSalts) TypeInfo() tdp.Type
TypeInfo returns info about TL type.
func (*FutureSalts) TypeName ¶ added in v0.28.0
func (*FutureSalts) TypeName() string
TypeName returns name of type in TL schema.
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.
type MessageContainer ¶
type MessageContainer struct {
Messages []Message
}
MessageContainer contains slice of messages.
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.
type MessageIDBuf ¶ added in v0.25.0
type MessageIDBuf struct {
// contains filtered or unexported fields
}
MessageIDBuf stores last N message ids and is used in replay attack mitigation.
func NewMessageIDBuf ¶ added in v0.25.0
func NewMessageIDBuf(n int) *MessageIDBuf
NewMessageIDBuf initializes new message id buffer for last N stored values.
func (*MessageIDBuf) Consume ¶ added in v0.25.0
func (b *MessageIDBuf) Consume(newID int64) bool
Consume returns false if message should be discarded.
type MessageIDGen ¶ added in v0.16.0
type MessageIDGen struct {
// contains filtered or unexported fields
}
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.
func NewMessageIDGen ¶ added in v0.16.0
func NewMessageIDGen(now func() time.Time, n int) *MessageIDGen
NewMessageIDGen creates new message id generator.
Current time will be provided by now() function. The n parameter configures capacity of message id history, bigger n results in bigger memory consumption.
func (*MessageIDGen) New ¶ added in v0.16.0
func (g *MessageIDGen) New(t MessageType) int64
New generates new message id for provided type, protecting from collisions that are caused by low system time resolution.
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 )
func (MessageType) String ¶ added in v0.19.0
func (m MessageType) String() string
type UnencryptedMessage ¶
UnencryptedMessage is plaintext message.