mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-24 08:14:14 +03:00
Fix creating new connections accessing invalid attributes
This commit is contained in:
parent
bfa3001f87
commit
b0f6b23e52
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user