Documentation ¶
Overview ¶
Package mtproto implements MTProto connection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cipher ¶
type Cipher interface { DecryptFromBuffer(k crypto.AuthKey, buf *bin.Buffer) (*crypto.EncryptedMessageData, error) Encrypt(key crypto.AuthKey, data crypto.EncryptedMessageData, b *bin.Buffer) error }
Cipher handles message encryption and decryption.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents a MTProto client to Telegram.
func (*Conn) Invoke ¶
Invoke sends input and decodes result into output.
NOTE: Assuming that call contains content message (seqno increment).
type MessageBuf ¶
MessageBuf is message id buffer.
type MessageIDSource ¶
type MessageIDSource interface {
New(t proto.MessageType) int64
}
MessageIDSource is message id generator.
type Options ¶
type Options struct { // DC is datacenter ID for key exchange. // Defaults to 2. DC int // PublicKeys of telegram. // // If not provided, embedded public keys will be used. PublicKeys []exchange.PublicKey // Random is random source. Defaults to crypto. Random io.Reader // Logger is instance of zap.Logger. No logs by default. Logger *zap.Logger // Handler will be called on received message. Handler Handler // AckBatchSize is maximum ack-s to buffer. AckBatchSize int // AckInterval is maximum time to buffer ack. AckInterval time.Duration // RetryInterval is duration between retries. RetryInterval time.Duration // MaxRetries is max retry count until rpc request failure. MaxRetries int // DialTimeout is timeout of creating connection. DialTimeout time.Duration // ExchangeTimeout is timeout of every key exchange request. ExchangeTimeout time.Duration // SaltFetchInterval is duration between get_future_salts request. SaltFetchInterval time.Duration // PingTimeout sets ping_delay_disconnect timeout. PingTimeout time.Duration // PingInterval is duration between ping_delay_disconnect request. PingInterval time.Duration // RequestTimeout is function which returns request timeout for given type ID. RequestTimeout func(req uint32) time.Duration // CompressThreshold is a threshold in bytes to determine that message // is large enough to be compressed using GZIP. // If < 0, compression will be disabled. // If == 0, default value will be used. CompressThreshold int // MessageID is message id source. Share source between connection to // reduce collision probability. MessageID MessageIDSource // Clock is current time source. Defaults to system time. Clock clock.Clock // Types map, used in verbose logging of incoming message. Types *tmap.Map // Key that can be used to restore previous connection. Key crypto.AuthKey // Salt from server that can be used to restore previous connection. Salt int64 // Tracer for OTEL. Tracer trace.Tracer // Cipher defines message crypto. Cipher Cipher // contains filtered or unexported fields }
Options of Conn.
Source Files ¶
- ack.go
- conn.go
- connect.go
- doc.go
- handle_ack.go
- handle_bad_msg.go
- handle_container.go
- handle_future_salts.go
- handle_gzip.go
- handle_message.go
- handle_result.go
- handle_session_created.go
- message_id.go
- new_encrypted_msg.go
- options.go
- ping.go
- read.go
- rpc.go
- salt.go
- session.go
- vendored_keys.go
- write.go
- zap.go
Click to show internal directories.
Click to hide internal directories.