mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-18 19:16:43 +00: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:
|
try:
|
||||||
if self._socket is None:
|
if self._socket is None:
|
||||||
self._socket = self._create_socket(mode, self.proxy)
|
self._socket = self._create_socket(mode, self.proxy)
|
||||||
if self.ssl and port == SSL_PORT:
|
wrap_ssl = self.ssl and port == SSL_PORT
|
||||||
self._socket = ssl.wrap_socket(self._socket, **self.ssl)
|
else:
|
||||||
|
wrap_ssl = False
|
||||||
|
|
||||||
await asyncio.wait_for(
|
await asyncio.wait_for(
|
||||||
self._loop.sock_connect(self._socket, address),
|
self._loop.sock_connect(self._socket, address),
|
||||||
timeout=self.timeout,
|
timeout=self.timeout,
|
||||||
loop=self._loop
|
loop=self._loop
|
||||||
)
|
)
|
||||||
|
if wrap_ssl:
|
||||||
|
self._socket = ssl.wrap_socket(self._socket, **self.ssl)
|
||||||
|
|
||||||
self._closed.clear()
|
self._closed.clear()
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.errno in CONN_RESET_ERRNOS:
|
if e.errno in CONN_RESET_ERRNOS:
|
||||||
|
Loading…
Reference in New Issue
Block a user