mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-03 21:24:35 +03:00
Wrap socket with SSL after connecting
See https://github.com/Anorov/PySocks/issues/29
This commit is contained in:
parent
7f78d7ed2f
commit
4027ac6a6f
|
@ -92,14 +92,18 @@ class TcpClient:
|
|||
try:
|
||||
if self._socket is None:
|
||||
self._socket = self._create_socket(mode, self.proxy)
|
||||
if self.ssl and port == SSL_PORT:
|
||||
self._socket = ssl.wrap_socket(self._socket, **self.ssl)
|
||||
wrap_ssl = self.ssl and port == SSL_PORT
|
||||
else:
|
||||
wrap_ssl = False
|
||||
|
||||
await asyncio.wait_for(
|
||||
self._loop.sock_connect(self._socket, address),
|
||||
timeout=self.timeout,
|
||||
loop=self._loop
|
||||
)
|
||||
if wrap_ssl:
|
||||
self._socket = ssl.wrap_socket(self._socket, **self.ssl)
|
||||
|
||||
self._closed.clear()
|
||||
except OSError as e:
|
||||
if e.errno in CONN_RESET_ERRNOS:
|
||||
|
|
Loading…
Reference in New Issue
Block a user