Documentation ¶
Overview ¶
Package transport contains different MTProto transport implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Abridged is abridged transport protocol. // // See https://core.telegram.org/mtproto/mtproto-transports#abridged Abridged = NewProtocol(func() Codec { return codec.Abridged{} }) // Intermediate is intermediate transport protocol. // // See https://core.telegram.org/mtproto/mtproto-transports#intermediate Intermediate = NewProtocol(func() Codec { return codec.Intermediate{} }) // PaddedIntermediate is padded intermediate transport protocol. // // See https://core.telegram.org/mtproto/mtproto-transports#padded-intermediate PaddedIntermediate = NewProtocol(func() Codec { return codec.PaddedIntermediate{} }) // Full is full transport protocol. // // See https://core.telegram.org/mtproto/mtproto-transports#full Full = NewProtocol(func() Codec { return &codec.Full{} }) )
Telegram transport protocols.
Functions ¶
func ObfuscatedListener ¶ added in v0.67.0
ObfuscatedListener creates new obfuscated2 listener using given net.Listener.
Useful for creating Telegram servers:
transport.Listen(transport.ObfuscatedListener(ln))
Types ¶
type Codec ¶
type Codec interface { // WriteHeader sends protocol tag if needed. WriteHeader(w io.Writer) error // ReadHeader reads protocol tag if needed. ReadHeader(r io.Reader) error // Write encode to writer message from given buffer. Write(w io.Writer, b *bin.Buffer) error // Read fills buffer with received message. Read(r io.Reader, b *bin.Buffer) error }
Codec is MTProto transport protocol encoding abstraction.
type Conn ¶ added in v0.12.0
type Conn interface { Send(ctx context.Context, b *bin.Buffer) error Recv(ctx context.Context, b *bin.Buffer) error Close() error }
Conn is transport connection.
type Listener ¶ added in v0.50.0
type Listener struct {
// contains filtered or unexported fields
}
Listener is a simple net.Listener wrapper for listening MTProto transport connections.
func Listen ¶ added in v0.50.0
Listen creates new Listener using given net.Listener. Transport codec will be detected automatically.
func ListenCodec ¶ added in v0.50.0
ListenCodec creates new Listener using given net.Listener. Listener will always use given Codec constructor.
func (Listener) Accept ¶ added in v0.50.0
Accept waits for and returns the next connection to the listener.
type Protocol ¶ added in v0.33.0
type Protocol struct {
// contains filtered or unexported fields
}
Protocol is MTProto transport protocol.
See https://core.telegram.org/mtproto/mtproto-transports
func NewProtocol ¶ added in v0.33.0
NewProtocol creates new transport protocol using user Codec constructor.
func (Protocol) CodecNoHeader ¶ added in v0.66.0
CodecNoHeader is Codec without header.