mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-04 04:00:18 +03:00
Remove broken packet length check
This commit is contained in:
parent
97f3dd809b
commit
fe299cc6cc
|
@ -185,26 +185,6 @@ class Connection:
|
||||||
# by asyncio?
|
# by asyncio?
|
||||||
packet_len_seq = await self.read(8) # 4 and 4
|
packet_len_seq = await self.read(8) # 4 and 4
|
||||||
packet_len, seq = struct.unpack('<ii', packet_len_seq)
|
packet_len, seq = struct.unpack('<ii', packet_len_seq)
|
||||||
|
|
||||||
# Sometimes Telegram seems to send a packet length of 0 (12)
|
|
||||||
# and after that, just a single byte. Not sure what this is.
|
|
||||||
# TODO Figure out what this is, and if there's a better fix.
|
|
||||||
if packet_len <= 12:
|
|
||||||
__log__.error('Read invalid packet length %d, '
|
|
||||||
'reading data left:', packet_len)
|
|
||||||
data = b''
|
|
||||||
try:
|
|
||||||
while True:
|
|
||||||
data += await self.read(1)
|
|
||||||
except TimeoutError:
|
|
||||||
pass
|
|
||||||
finally:
|
|
||||||
__log__.error(repr(data))
|
|
||||||
|
|
||||||
# Connection reset and hope it's fixed after
|
|
||||||
self.conn.close()
|
|
||||||
raise ConnectionResetError()
|
|
||||||
|
|
||||||
body = await self.read(packet_len - 12)
|
body = await self.read(packet_len - 12)
|
||||||
checksum = struct.unpack('<I', await self.read(4))[0]
|
checksum = struct.unpack('<I', await self.read(4))[0]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user