diff --git a/telethon/extensions/tcp_client.py b/telethon/extensions/tcp_client.py index 3879bcd3..6feb9841 100644 --- a/telethon/extensions/tcp_client.py +++ b/telethon/extensions/tcp_client.py @@ -8,7 +8,7 @@ from threading import Lock class TcpClient: def __init__(self, proxy=None, timeout=timedelta(seconds=5)): - self._proxy = proxy + self.proxy = proxy self._socket = None self._closing_lock = Lock() @@ -20,15 +20,15 @@ class TcpClient: raise ValueError('Invalid timeout type', type(timeout)) def _recreate_socket(self, mode): - if self._proxy is None: + if self.proxy is None: self._socket = socket.socket(mode, socket.SOCK_STREAM) else: import socks self._socket = socks.socksocket(mode, socket.SOCK_STREAM) - if type(self._proxy) is dict: - self._socket.set_proxy(**self._proxy) + if type(self.proxy) is dict: + self._socket.set_proxy(**self.proxy) else: # tuple, list, etc. - self._socket.set_proxy(*self._proxy) + self._socket.set_proxy(*self.proxy) self._socket.settimeout(self.timeout) diff --git a/telethon/telegram_bare_client.py b/telethon/telegram_bare_client.py index 401d3982..4fb1e60f 100644 --- a/telethon/telegram_bare_client.py +++ b/telethon/telegram_bare_client.py @@ -276,7 +276,8 @@ class TelegramBareClient: session.port = dc.port client = TelegramBareClient( session, self.api_id, self.api_hash, - timeout=self._connection.get_timeout() + proxy=self._sender.connection.conn.proxy, + timeout=self._sender.connection.get_timeout() ) client.connect(exported_auth=export_auth) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 2f848434..18f305ac 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -225,7 +225,7 @@ class TelegramClient(TelegramBareClient): if on_dc is None: client = TelegramBareClient( self.session, self.api_id, self.api_hash, - proxy=self.proxy, timeout=timeout + proxy=self._sender.connection.conn.proxy, timeout=timeout ) client.connect() else: