mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-13 17:42:29 +03:00
fix: resolve flagged issues in review by Lonami
This commit is contained in:
parent
9876cd6e77
commit
003b6aebb8
|
@ -776,7 +776,7 @@ class TelegramBaseClient(abc.ABC):
|
||||||
def _tmp_auth_key_callback(self: 'TelegramClient', tmp_auth_key):
|
def _tmp_auth_key_callback(self: 'TelegramClient', tmp_auth_key):
|
||||||
"""
|
"""
|
||||||
Callback from the sender whenever it needed to generate a
|
Callback from the sender whenever it needed to generate a
|
||||||
new authorization key. This means we are not authorized.
|
new temporary authorization key. This means we are not authorized.
|
||||||
"""
|
"""
|
||||||
self.session.tmp_auth_key = tmp_auth_key
|
self.session.tmp_auth_key = tmp_auth_key
|
||||||
self.session.save()
|
self.session.save()
|
||||||
|
|
|
@ -260,7 +260,7 @@ class MTProtoSender:
|
||||||
# establish tmp_auth_key here, but make sure to bind to the auth_key later
|
# establish tmp_auth_key here, but make sure to bind to the auth_key later
|
||||||
try:
|
try:
|
||||||
if not await self._try_gen_tmp_auth_key(attempt):
|
if not await self._try_gen_tmp_auth_key(attempt):
|
||||||
continue # keep retrying until we have the tmp auth key
|
continue # keep retrying until we have the tmp auth key
|
||||||
except (IOError, asyncio.TimeoutError) as e:
|
except (IOError, asyncio.TimeoutError) as e:
|
||||||
# Sometimes, specially during user-DC migrations,
|
# Sometimes, specially during user-DC migrations,
|
||||||
# Telegram may close the connection during auth_key
|
# Telegram may close the connection during auth_key
|
||||||
|
|
|
@ -171,7 +171,9 @@ class MTProtoState:
|
||||||
bind = bytes(bind)
|
bind = bytes(bind)
|
||||||
assert len(bind) == 40
|
assert len(bind) == 40
|
||||||
|
|
||||||
payload = os.urandom(int(128/8)) + struct.pack('<qii', msg_id, seq_no, len(bind)) + bind
|
# 128 bit random + msg_id + seq_no + len(bind) + bind
|
||||||
|
payload = os.urandom(128//8) + struct.pack('<qii', msg_id, seq_no, len(bind)) + bind
|
||||||
|
# 16-byte alignment
|
||||||
padding = os.urandom(len(payload) % 16)
|
padding = os.urandom(len(payload) % 16)
|
||||||
|
|
||||||
msg_key = sha1(payload).digest()[4:20]
|
msg_key = sha1(payload).digest()[4:20]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user