From f0b9503c0b58652bdd84e502c5fcc5e1b7da3c94 Mon Sep 17 00:00:00 2001 From: Confused Character <121636230+ConfusedCharacter@users.noreply.github.com> Date: Fri, 16 Feb 2024 20:24:21 +0330 Subject: [PATCH] Update tcpmtproxy.py --- telethon/network/connection/tcpmtproxy.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/telethon/network/connection/tcpmtproxy.py b/telethon/network/connection/tcpmtproxy.py index 81c2b500..55710417 100644 --- a/telethon/network/connection/tcpmtproxy.py +++ b/telethon/network/connection/tcpmtproxy.py @@ -1,4 +1,3 @@ -import binascii import asyncio import hashlib import base64 @@ -140,11 +139,8 @@ class TcpMTProxy(ObfuscatedConnection): try: secret_bytes = bytes.fromhex(secret) except ValueError: - try: - secret_bytes = base64.b64decode(secret.encode()) - except binascii.Error: - secret = secret + "==" - secret_bytes = base64.b64decode(secret.encode()) + secret = secret + '=' * (-len(s) % 4) + secret_bytes = base64.b64decode(secret.encode()) return secret_bytes[:16] # Remove the domain from the secret (until domain support is added) @@ -166,4 +162,4 @@ class ConnectionTcpMTProxyRandomizedIntermediate(TcpMTProxy): """ Connect to proxy using randomized intermediate protocol (dd-secrets) """ - packet_codec = RandomizedIntermediatePacketCodec \ No newline at end of file + packet_codec = RandomizedIntermediatePacketCodec