Documentation ¶
Index ¶
- Constants
- func AddObjectConstructor(c ...CustomObjectConstructor)
- type BadMsgNotification
- type BadServerSalt
- type Bool
- type ClientDHInnerData
- type CommonMessage
- type CustomObjectConstructor
- type DHGenFail
- type DHGenOk
- type DHGenRetry
- type Decoder
- func (d *Decoder) GetRestOfMessage() []byte
- func (d *Decoder) PopBigInt() *big.Int
- func (d *Decoder) PopBool() bool
- func (d *Decoder) PopCRC() uint32
- func (d *Decoder) PopDouble() float64
- func (d *Decoder) PopInt() int32
- func (d *Decoder) PopInt128() *Int128
- func (d *Decoder) PopInt256() *Int256
- func (d *Decoder) PopLong() int64
- func (d *Decoder) PopMessage() []byte
- func (d *Decoder) PopNull() interface{}
- func (d *Decoder) PopObj() TL
- func (d *Decoder) PopRawBytes(size int) []byte
- func (d *Decoder) PopString() string
- func (d *Decoder) PopToObjUsingReflection(item TL, ignoreCRCReading bool)
- func (d *Decoder) PopUint() uint32
- func (d *Decoder) PopVector(as reflect.Type) interface{}
- type Encoder
- func (e *Encoder) GetBuffer() []byte
- func (e *Encoder) PutBigInt(s *big.Int)
- func (e *Encoder) PutBool(v bool)
- func (e *Encoder) PutCRC(v uint32)
- func (e *Encoder) PutDouble(v float64)
- func (e *Encoder) PutInt(v int32)
- func (e *Encoder) PutInt128(s *Int128)
- func (e *Encoder) PutInt256(s *Int256)
- func (e *Encoder) PutLong(v int64)
- func (e *Encoder) PutMessage(msg []byte)
- func (e *Encoder) PutRawBytes(s []byte)
- func (e *Encoder) PutString(msg string)
- func (e *Encoder) PutUint(v uint32)
- func (e *Encoder) PutVector(v interface{})
- func (e *Encoder) Result() []byte
- type EncryptedMessage
- type ErrorSessionConfigsChanged
- type FutureSalt
- type FutureSalts
- type GzipPacked
- type InnerVectorObject
- type Int
- type Int128
- type Int256
- type Long
- type Message
- type MessageContainer
- type MessageInformator
- type MsgCopy
- type MsgResendReq
- type MsgsAck
- type MsgsAllInfo
- type MsgsDetailedInfo
- type MsgsNewDetailedInfo
- type MsgsStateInfo
- type MsgsStateReq
- type NewSessionCreated
- type Null
- type PQInnerData
- type Pong
- type ResPQ
- type RpcAnswerDropped
- type RpcAnswerDroppedRunning
- type RpcAnswerUnknown
- type RpcError
- type RpcResult
- type ServerDHInnerData
- type ServerDHParams
- type ServerDHParamsFail
- type ServerDHParamsOk
- type SetClientDHParamsAnswer
- type TL
- type TLDecoder
- type TLEncoder
- type UnencryptedMessage
Constants ¶
const ( WordLen = 4 // размер слова в TL (32 бита) LongLen = WordLen * 2 // int64 8 байт занимает DoubleLen = WordLen * 2 // float64 8 байт занимает Int128Len = WordLen * 4 // int128 16 байт Int256Len = WordLen * 8 // int256 32 байт // Блядские магические числа FuckingMagicNumber = 254 // 253 элемента максимум можно закодировать в массиве элементов ByteLenMagicNumber = 0xfe // ??? // CrcRpcResult публичная переменная, т.к. это специфический конструктор CrcRpcResult = 0xf35c6d01 // nolint CrcGzipPacked = 0x3072cfa1 )
Variables ¶
This section is empty.
Functions ¶
func AddObjectConstructor ¶
func AddObjectConstructor(c ...CustomObjectConstructor)
Types ¶
type BadMsgNotification ¶
func (*BadMsgNotification) CRC ¶
func (_ *BadMsgNotification) CRC() uint32
func (*BadMsgNotification) DecodeFrom ¶
func (t *BadMsgNotification) DecodeFrom(d *Decoder)
func (*BadMsgNotification) Encode ¶
func (t *BadMsgNotification) Encode() []byte
func (*BadMsgNotification) ImplementsBadMsgNotification ¶
func (t *BadMsgNotification) ImplementsBadMsgNotification()
type BadServerSalt ¶
func (*BadServerSalt) CRC ¶
func (_ *BadServerSalt) CRC() uint32
func (*BadServerSalt) DecodeFrom ¶
func (t *BadServerSalt) DecodeFrom(d *Decoder)
func (*BadServerSalt) Encode ¶
func (t *BadServerSalt) Encode() []byte
func (*BadServerSalt) ImplementsBadMsgNotification ¶
func (t *BadServerSalt) ImplementsBadMsgNotification()
type ClientDHInnerData ¶
func (*ClientDHInnerData) CRC ¶
func (_ *ClientDHInnerData) CRC() uint32
func (*ClientDHInnerData) DecodeFrom ¶
func (t *ClientDHInnerData) DecodeFrom(d *Decoder)
func (*ClientDHInnerData) Encode ¶
func (t *ClientDHInnerData) Encode() []byte
type CommonMessage ¶
CommonMessage это сообщение (зашифрованое либо открытое) которыми общаются между собой клиент и сервер
type CustomObjectConstructor ¶
type DHGenFail ¶
func (*DHGenFail) DecodeFrom ¶
func (*DHGenFail) ImplementsSetClientDHParamsAnswer ¶
func (t *DHGenFail) ImplementsSetClientDHParamsAnswer()
type DHGenOk ¶
func (*DHGenOk) DecodeFrom ¶
func (*DHGenOk) ImplementsSetClientDHParamsAnswer ¶
func (t *DHGenOk) ImplementsSetClientDHParamsAnswer()
type DHGenRetry ¶
func (*DHGenRetry) CRC ¶
func (_ *DHGenRetry) CRC() uint32
func (*DHGenRetry) DecodeFrom ¶
func (t *DHGenRetry) DecodeFrom(d *Decoder)
func (*DHGenRetry) Encode ¶
func (t *DHGenRetry) Encode() []byte
func (*DHGenRetry) ImplementsSetClientDHParamsAnswer ¶
func (t *DHGenRetry) ImplementsSetClientDHParamsAnswer()
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶
func (*Decoder) GetRestOfMessage ¶
func (*Decoder) PopMessage ¶
func (*Decoder) PopObj ¶
PopObj создает структуру исходя из кода объекта, который находится в буффере. Следует использовать только вкупе с функциями-генераторами, которые должны быть объявлены в CustomDecoders. поиск и создание объекта выполняется в том порядке, в котором были объявлены сами функции в CustomDecoders.
func (*Decoder) PopRawBytes ¶
func (*Decoder) PopToObjUsingReflection ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func NewEncoder ¶
func NewEncoder() *Encoder
func (*Encoder) PutBool ¶
PutBool очень специфичный тип, т.к. есть отдельный конструктор под true и false, то можно считать, что это две crc константы
func (*Encoder) PutMessage ¶
func (*Encoder) PutRawBytes ¶
type EncryptedMessage ¶
type EncryptedMessage struct { Msg []byte MsgID int64 AuthKeyHash []byte Salt int64 SessionID int64 SeqNo int32 MsgKey []byte }
func DeserializeEncryptedMessage ¶
func DeserializeEncryptedMessage(data, authKey []byte) (*EncryptedMessage, error)
func (*EncryptedMessage) GetMsg ¶
func (msg *EncryptedMessage) GetMsg() []byte
func (*EncryptedMessage) GetMsgID ¶
func (msg *EncryptedMessage) GetMsgID() int
func (*EncryptedMessage) GetSeqNo ¶
func (msg *EncryptedMessage) GetSeqNo() int
func (*EncryptedMessage) Serialize ¶
func (msg *EncryptedMessage) Serialize(client MessageInformator, requireToAck bool) ([]byte, error)
type ErrorSessionConfigsChanged ¶
type ErrorSessionConfigsChanged struct { }
ErrorSessionConfigsChanged это пустой объект, который показывает, что конфигурация сессии изменилась, и нужно создавать новую
func (*ErrorSessionConfigsChanged) CRC ¶
func (*ErrorSessionConfigsChanged) CRC() uint32
func (*ErrorSessionConfigsChanged) DecodeFrom ¶
func (*ErrorSessionConfigsChanged) DecodeFrom(d *Decoder)
func (*ErrorSessionConfigsChanged) Encode ¶
func (*ErrorSessionConfigsChanged) Encode() []byte
func (*ErrorSessionConfigsChanged) Error ¶
func (*ErrorSessionConfigsChanged) Error() string
type FutureSalt ¶
func (*FutureSalt) CRC ¶
func (_ *FutureSalt) CRC() uint32
func (*FutureSalt) DecodeFrom ¶
func (t *FutureSalt) DecodeFrom(d *Decoder)
func (*FutureSalt) Encode ¶
func (t *FutureSalt) Encode() []byte
type FutureSalts ¶
type FutureSalts struct { ReqMsgID int64 Now int32 Salts []*FutureSalt }
func (*FutureSalts) CRC ¶
func (_ *FutureSalts) CRC() uint32
func (*FutureSalts) DecodeFrom ¶
func (t *FutureSalts) DecodeFrom(d *Decoder)
func (*FutureSalts) Encode ¶
func (t *FutureSalts) Encode() []byte
type GzipPacked ¶
type GzipPacked struct {
Obj TL
}
func (*GzipPacked) CRC ¶
func (*GzipPacked) CRC() uint32
func (*GzipPacked) DecodeFrom ¶
func (t *GzipPacked) DecodeFrom(d *Decoder)
func (*GzipPacked) DecodeFromButItsVector ¶
func (t *GzipPacked) DecodeFromButItsVector(d *Decoder, as reflect.Type)
func (*GzipPacked) Encode ¶
func (*GzipPacked) Encode() []byte
type InnerVectorObject ¶
type InnerVectorObject struct {
I interface{}
}
блять! вектор ведь это тоже структура! короче вот эта структура просто в себе хранит слайс либо стандартных типов ([]int32, []float64, []bool и прочее), либо тл объекта ([]TL). алгоритм который использует эту структуру должен гарантировать, что параметр является слайсом, а элементы слайса являются либо стандартные типы, либо TL.
func (*InnerVectorObject) CRC ¶
func (*InnerVectorObject) CRC() uint32
func (*InnerVectorObject) Encode ¶
func (*InnerVectorObject) Encode() []byte
type MessageContainer ¶
type MessageContainer []*EncryptedMessage
! исключение из правил: это оказывается почти-вектор, т.к.
записан как `msg_container#73f1f8dc messages:vector<%Message> = MessageContainer;` судя по всему, <%Type> означает, что может это неявный вектор???
! возможно разработчики в этот момент поехаи кукухой, я не знаю правда
func (*MessageContainer) CRC ¶
func (_ *MessageContainer) CRC() uint32
func (*MessageContainer) DecodeFrom ¶
func (t *MessageContainer) DecodeFrom(d *Decoder)
func (*MessageContainer) Encode ¶
func (t *MessageContainer) Encode() []byte
type MessageInformator ¶
type MessageInformator interface { GetSessionID() int64 GetLastSeqNo() int32 GetServerSalt() int64 GetAuthKey() []byte MakeRequest(msg TL) (TL, error) }
MessageInformator нужен что бы отдавать информацию о текущей сессии для сериализации сообщения по факту это *MTProto структура
type MsgResendReq ¶
type MsgResendReq struct {
MsgIds []int64
}
func (*MsgResendReq) CRC ¶
func (_ *MsgResendReq) CRC() uint32
func (*MsgResendReq) DecodeFrom ¶
func (t *MsgResendReq) DecodeFrom(d *Decoder)
func (*MsgResendReq) Encode ¶
func (t *MsgResendReq) Encode() []byte
type MsgsAllInfo ¶
func (*MsgsAllInfo) CRC ¶
func (_ *MsgsAllInfo) CRC() uint32
func (*MsgsAllInfo) DecodeFrom ¶
func (t *MsgsAllInfo) DecodeFrom(d *Decoder)
func (*MsgsAllInfo) Encode ¶
func (t *MsgsAllInfo) Encode() []byte
type MsgsDetailedInfo ¶
func (*MsgsDetailedInfo) CRC ¶
func (_ *MsgsDetailedInfo) CRC() uint32
func (*MsgsDetailedInfo) DecodeFrom ¶
func (t *MsgsDetailedInfo) DecodeFrom(d *Decoder)
func (*MsgsDetailedInfo) Encode ¶
func (t *MsgsDetailedInfo) Encode() []byte
type MsgsNewDetailedInfo ¶
func (*MsgsNewDetailedInfo) CRC ¶
func (_ *MsgsNewDetailedInfo) CRC() uint32
func (*MsgsNewDetailedInfo) DecodeFrom ¶
func (t *MsgsNewDetailedInfo) DecodeFrom(d *Decoder)
func (*MsgsNewDetailedInfo) Encode ¶
func (t *MsgsNewDetailedInfo) Encode() []byte
type MsgsStateInfo ¶
func (*MsgsStateInfo) CRC ¶
func (_ *MsgsStateInfo) CRC() uint32
func (*MsgsStateInfo) DecodeFrom ¶
func (t *MsgsStateInfo) DecodeFrom(d *Decoder)
func (*MsgsStateInfo) Encode ¶
func (t *MsgsStateInfo) Encode() []byte
type MsgsStateReq ¶
type MsgsStateReq struct {
MsgIds []int64
}
func (*MsgsStateReq) CRC ¶
func (_ *MsgsStateReq) CRC() uint32
func (*MsgsStateReq) DecodeFrom ¶
func (t *MsgsStateReq) DecodeFrom(d *Decoder)
func (*MsgsStateReq) Encode ¶
func (t *MsgsStateReq) Encode() []byte
type NewSessionCreated ¶
func (*NewSessionCreated) CRC ¶
func (_ *NewSessionCreated) CRC() uint32
func (*NewSessionCreated) DecodeFrom ¶
func (t *NewSessionCreated) DecodeFrom(d *Decoder)
func (*NewSessionCreated) Encode ¶
func (t *NewSessionCreated) Encode() []byte
type Null ¶
type Null struct { }
TL_Null это пустой объект, который нужен для передачи в каналы TL с информацией, что ответа можно не ждать
func (*Null) DecodeFrom ¶
type PQInnerData ¶
type PQInnerData struct { Pq []byte P []byte Q []byte Nonce *Int128 ServerNonce *Int128 NewNonce *Int256 }
func (*PQInnerData) CRC ¶
func (_ *PQInnerData) CRC() uint32
func (*PQInnerData) DecodeFrom ¶
func (e *PQInnerData) DecodeFrom(d *Decoder)
func (*PQInnerData) Encode ¶
func (t *PQInnerData) Encode() []byte
type Pong ¶
func (*Pong) DecodeFrom ¶
type ResPQ ¶
func (*ResPQ) DecodeFrom ¶
type RpcAnswerDropped ¶
func (*RpcAnswerDropped) CRC ¶
func (_ *RpcAnswerDropped) CRC() uint32
func (*RpcAnswerDropped) DecodeFrom ¶
func (t *RpcAnswerDropped) DecodeFrom(d *Decoder)
func (*RpcAnswerDropped) Encode ¶
func (t *RpcAnswerDropped) Encode() []byte
func (*RpcAnswerDropped) ImplementsRpcDropAnswer ¶
func (t *RpcAnswerDropped) ImplementsRpcDropAnswer()
type RpcAnswerDroppedRunning ¶
type RpcAnswerDroppedRunning struct{}
func (*RpcAnswerDroppedRunning) CRC ¶
func (_ *RpcAnswerDroppedRunning) CRC() uint32
func (*RpcAnswerDroppedRunning) DecodeFrom ¶
func (t *RpcAnswerDroppedRunning) DecodeFrom(d *Decoder)
func (*RpcAnswerDroppedRunning) Encode ¶
func (t *RpcAnswerDroppedRunning) Encode() []byte
func (*RpcAnswerDroppedRunning) ImplementsRpcDropAnswer ¶
func (t *RpcAnswerDroppedRunning) ImplementsRpcDropAnswer()
type RpcAnswerUnknown ¶
type RpcAnswerUnknown struct{}
func (*RpcAnswerUnknown) CRC ¶
func (_ *RpcAnswerUnknown) CRC() uint32
func (*RpcAnswerUnknown) DecodeFrom ¶
func (t *RpcAnswerUnknown) DecodeFrom(d *Decoder)
func (*RpcAnswerUnknown) Encode ¶
func (t *RpcAnswerUnknown) Encode() []byte
func (*RpcAnswerUnknown) ImplementsRpcDropAnswer ¶
func (t *RpcAnswerUnknown) ImplementsRpcDropAnswer()
type RpcError ¶
func (*RpcError) DecodeFrom ¶
type RpcResult ¶
func (*RpcResult) DecodeFrom ¶
func (*RpcResult) DecodeFromButItsVector ¶
DecodeFromButItsVector декодирует ТАК ЖЕ как DecodeFrom, но за тем исключением, что достает не объект, а слайс. проблема в том, что вектор (слайс) в понятиях MTProto это как-бы объект, но вот как бы и нет технически, эта функция — костыль, т.к. нет никакого внятного способа передать декодеру информацию, что нужно доставать вектор (ведь RPC Result это всегда объекты, но вектор тоже объект, кто бы мог подумать) другими словами: т.к. telegram отсылает на реквесты сообщения (messages, TL в рамках этого пакета) НО! иногда на некоторые запросы приходят ответы в виде вектора. Просто потому что. поэтому этот кусочек возвращает корявое апи к его же описанию — ответы это всегда объекты.
type ServerDHInnerData ¶
type ServerDHInnerData struct { Nonce *Int128 ServerNonce *Int128 G int32 DhPrime []byte GA []byte ServerTime int32 }
func (*ServerDHInnerData) CRC ¶
func (_ *ServerDHInnerData) CRC() uint32
func (*ServerDHInnerData) DecodeFrom ¶
func (t *ServerDHInnerData) DecodeFrom(d *Decoder)
func (*ServerDHInnerData) Encode ¶
func (t *ServerDHInnerData) Encode() []byte
type ServerDHParams ¶
type ServerDHParams interface { TL ImplementsServerDHParams() }
type ServerDHParamsFail ¶
func (*ServerDHParamsFail) CRC ¶
func (_ *ServerDHParamsFail) CRC() uint32
func (*ServerDHParamsFail) DecodeFrom ¶
func (t *ServerDHParamsFail) DecodeFrom(d *Decoder)
func (*ServerDHParamsFail) Encode ¶
func (t *ServerDHParamsFail) Encode() []byte
func (*ServerDHParamsFail) ImplementsServerDHParams ¶
func (t *ServerDHParamsFail) ImplementsServerDHParams()
type ServerDHParamsOk ¶
func (*ServerDHParamsOk) CRC ¶
func (_ *ServerDHParamsOk) CRC() uint32
func (*ServerDHParamsOk) DecodeFrom ¶
func (t *ServerDHParamsOk) DecodeFrom(d *Decoder)
func (*ServerDHParamsOk) Encode ¶
func (t *ServerDHParamsOk) Encode() []byte
func (*ServerDHParamsOk) ImplementsServerDHParams ¶
func (t *ServerDHParamsOk) ImplementsServerDHParams()
type SetClientDHParamsAnswer ¶
type SetClientDHParamsAnswer interface { TL ImplementsSetClientDHParamsAnswer() }
type UnencryptedMessage ¶
func DeserializeUnencryptedMessage ¶
func DeserializeUnencryptedMessage(data []byte) (*UnencryptedMessage, error)
func (*UnencryptedMessage) GetMsg ¶
func (msg *UnencryptedMessage) GetMsg() []byte
func (*UnencryptedMessage) GetMsgID ¶
func (msg *UnencryptedMessage) GetMsgID() int
func (*UnencryptedMessage) GetSeqNo ¶
func (msg *UnencryptedMessage) GetSeqNo() int
func (*UnencryptedMessage) Serialize ¶
func (msg *UnencryptedMessage) Serialize(client MessageInformator) ([]byte, error)