Move the "unknown constructor found" logging logic
This commit is contained in:
parent
975ff219f2
commit
89e590b968
@ -60,7 +60,16 @@ def unpack(b: BytesIO, session_id: bytes, auth_key: bytes, auth_key_id: bytes) -
|
||||
# https://core.telegram.org/mtproto/security_guidelines#checking-session-id
|
||||
assert data.read(8) == session_id
|
||||
|
||||
try:
|
||||
message = Message.read(data)
|
||||
except KeyError as e:
|
||||
left = data.read().hex()
|
||||
|
||||
left = [left[i:i + 64] for i in range(0, len(left), 64)]
|
||||
left = [[left[i:i + 8] for i in range(0, len(left), 8)] for left in left]
|
||||
left = "\n".join(" ".join(x for x in left) for left in left)
|
||||
|
||||
raise ValueError(f"Unknown constructor found: {hex(e.args[0])}\n{left}")
|
||||
|
||||
# https://core.telegram.org/mtproto/security_guidelines#checking-sha256-hash-value-of-msg-key
|
||||
# https://core.telegram.org/mtproto/security_guidelines#checking-message-length
|
||||
|
@ -30,16 +30,7 @@ class TLObject:
|
||||
|
||||
@classmethod
|
||||
def read(cls, data: BytesIO, *args: Any) -> Any:
|
||||
try:
|
||||
return cast(TLObject, objects[int.from_bytes(data.read(4), "little")]).read(data, *args)
|
||||
except KeyError as e:
|
||||
left = data.read().hex()
|
||||
|
||||
left = [left[i:i + 64] for i in range(0, len(left), 64)]
|
||||
left = [[left[i:i + 8] for i in range(0, len(left), 8)] for left in left]
|
||||
left = "\n".join(" ".join(x for x in left) for left in left)
|
||||
|
||||
raise ValueError(f"Unknown constructor found: {hex(e.args[0])}\n{left}")
|
||||
|
||||
def write(self, *args: Any) -> bytes:
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user