|
|
@@ -1,6 +1,8 @@ |
|
|
|
import asyncio |
|
|
|
import socket |
|
|
|
import struct |
|
|
|
from asyncio import sslproto |
|
|
|
|
|
|
|
from . import constants as c |
|
|
|
from .helpers import ( |
|
|
|
Socks4Addr, Socks5Addr, Socks5Auth, Socks4Auth |
|
|
@@ -67,20 +69,20 @@ class BaseSocksProtocol(asyncio.StreamReaderProtocol): |
|
|
|
if self._ssl: |
|
|
|
# Creating a ssl transport needs to be reworked. |
|
|
|
# See details: http://bugs.python.org/issue23749 |
|
|
|
sock = self._transport.get_extra_info('socket') |
|
|
|
|
|
|
|
# temporary fix: |
|
|
|
self._transport.pause_reading() |
|
|
|
self._transport._closing = True |
|
|
|
self._transport._sock = None |
|
|
|
self._transport._protocol = None |
|
|
|
self._transport._loop = None |
|
|
|
|
|
|
|
self._transport = self._loop._make_ssl_transport( |
|
|
|
rawsock=sock, protocol=self._app_protocol, |
|
|
|
sslcontext=self._ssl, server_side=False, |
|
|
|
server_hostname=self._server_hostname, |
|
|
|
waiter=self._waiter) |
|
|
|
self._tls_protocol = sslproto.SSLProtocol( |
|
|
|
app_protocol=self, sslcontext=self._ssl, server_side=False, |
|
|
|
server_hostname=self._server_hostname, waiter=self._waiter, |
|
|
|
loop=self._loop, call_connection_made=False) |
|
|
|
|
|
|
|
# starttls |
|
|
|
original_transport = self._transport |
|
|
|
self._transport.set_protocol(self._tls_protocol) |
|
|
|
self._transport = self._tls_protocol._app_transport |
|
|
|
|
|
|
|
self._tls_protocol.connection_made(original_transport) |
|
|
|
|
|
|
|
self._loop.call_soon(self._app_protocol.connection_made, |
|
|
|
self._transport) |
|
|
|
else: |
|
|
|
self._loop.call_soon(self._app_protocol.connection_made, |
|
|
|
self._transport) |
|
|
|