Connection Modes
The only part about network that you should worry about are the different connection modes, which are the following:
- class telethon.network.connection.tcpfull.ConnectionTcpFull(ip, port, dc_id, *, loggers, proxy=None, local_addr=None)
Bases:
telethon.network.connection.connection.ConnectionDefault Telegram mode. Sends 12 additional bytes and needs to calculate the CRC value of the packet itself.
- __annotations__ = {}
- packet_codec
alias of
telethon.network.connection.tcpfull.FullPacketCodec
- class telethon.network.connection.tcpfull.FullPacketCodec(connection)
Bases:
telethon.network.connection.connection.PacketCodec- __annotations__ = {}
- encode_packet(data)
Encodes single packet and returns encoded bytes.
- async read_packet(reader)
Reads single packet from
readerobject that should havereadexactly(n)method.
- tag = None
- class telethon.network.connection.tcpabridged.AbridgedPacketCodec(connection)
Bases:
telethon.network.connection.connection.PacketCodec- __annotations__ = {}
- encode_packet(data)
Encodes single packet and returns encoded bytes.
- obfuscate_tag = b'\xef\xef\xef\xef'
- async read_packet(reader)
Reads single packet from
readerobject that should havereadexactly(n)method.
- tag = b'\xef'
- class telethon.network.connection.tcpabridged.ConnectionTcpAbridged(ip, port, dc_id, *, loggers, proxy=None, local_addr=None)
Bases:
telethon.network.connection.connection.ConnectionThis is the mode with the lowest overhead, as it will only require 1 byte if the packet length is less than 508 bytes (127 << 2, which is very common).
- __annotations__ = {}
- packet_codec
alias of
telethon.network.connection.tcpabridged.AbridgedPacketCodec
- class telethon.network.connection.tcpintermediate.ConnectionTcpIntermediate(ip, port, dc_id, *, loggers, proxy=None, local_addr=None)
Bases:
telethon.network.connection.connection.ConnectionIntermediate mode between
ConnectionTcpFullandConnectionTcpAbridged. Always sends 4 extra bytes for the packet length.- __annotations__ = {}
- packet_codec
alias of
telethon.network.connection.tcpintermediate.IntermediatePacketCodec
- class telethon.network.connection.tcpintermediate.IntermediatePacketCodec(connection)
Bases:
telethon.network.connection.connection.PacketCodec- __annotations__ = {}
- encode_packet(data)
Encodes single packet and returns encoded bytes.
- obfuscate_tag = b'\xee\xee\xee\xee'
- async read_packet(reader)
Reads single packet from
readerobject that should havereadexactly(n)method.
- tag = b'\xee\xee\xee\xee'
- class telethon.network.connection.tcpintermediate.RandomizedIntermediatePacketCodec(connection)
Bases:
telethon.network.connection.tcpintermediate.IntermediatePacketCodecData packets are aligned to 4bytes. This codec adds random bytes of size from 0 to 3 bytes, which are ignored by decoder.
- __annotations__ = {}
- encode_packet(data)
Encodes single packet and returns encoded bytes.
- obfuscate_tag = b'\xdd\xdd\xdd\xdd'
- async read_packet(reader)
Reads single packet from
readerobject that should havereadexactly(n)method.
- tag = None
- class telethon.network.connection.tcpobfuscated.ConnectionTcpObfuscated(ip, port, dc_id, *, loggers, proxy=None, local_addr=None)
Bases:
telethon.network.connection.connection.ObfuscatedConnectionMode that Telegram defines as “obfuscated2”. Encodes the packet just like
ConnectionTcpAbridged, but encrypts every message with a randomly generated key using the AES-CTR mode so the packets are harder to discern.- __annotations__ = {}
- obfuscated_io
alias of
telethon.network.connection.tcpobfuscated.ObfuscatedIO
- packet_codec
alias of
telethon.network.connection.tcpabridged.AbridgedPacketCodec
- class telethon.network.connection.tcpobfuscated.ObfuscatedIO(connection)
Bases:
object- __weakref__
list of weak references to the object (if defined)
- header = None
- static init_header(packet_codec)
- async readexactly(n)
- write(data)
- class telethon.network.connection.http.ConnectionHttp(ip, port, dc_id, *, loggers, proxy=None, local_addr=None)
Bases:
telethon.network.connection.connection.Connection- __annotations__ = {}
- async connect(timeout=None, ssl=None)
Establishes a connection with the server.
- packet_codec
- class telethon.network.connection.http.HttpPacketCodec(connection)
Bases:
telethon.network.connection.connection.PacketCodec- __annotations__ = {}
- encode_packet(data)
Encodes single packet and returns encoded bytes.
- obfuscate_tag = None
- async read_packet(reader)
Reads single packet from
readerobject that should havereadexactly(n)method.
- tag = None