Compare commits

..

1 Commits

Author SHA1 Message Date
Josiah Baldwin
e226fff8dd Merge pull request #36 from HuFlungDu/hotfix/1.1.2
Hotfix/1.1.2

Fixes #35 

Update Cryptography version to fix SSL vulnerability.
2025-02-17 12:11:08 -08:00
8 changed files with 23 additions and 15 deletions

View File

@@ -8,5 +8,5 @@ sphinx-toolbox>=2.16.0
cffi~=1.17.1
cryptography~=44.0.1
pycparser~=2.22
websockets~=15.0.0
websockets~=14.2
enum_tools

Binary file not shown.

View File

@@ -45,7 +45,7 @@ python_requires = >=3.8
install_requires =
importlib-metadata
cryptography~=44.0.1
websockets~=15.0.0
websockets~=14.2
python-socks[asyncio]~=2.5.3

View File

@@ -144,7 +144,7 @@ class Session(object):
options["additional_headers"] = headers
async for websocket in websockets.asyncio.client.connect(self.url, proxy=self._proxy, process_exception=util._process_websocket_exception, **options):
async for websocket in util.proxy_connect(self.url, proxy_url=self._proxy, process_exception=util._process_websocket_exception, **options):
self.alive = True
self._socket_open.set()
try:

View File

@@ -67,7 +67,7 @@ class Tunnel(object):
self.url = self._session.url.replace('/control.ashx', '/meshrelay.ashx?browser=1&p=' + str(self._protocol) + '&nodeid=' + self.node_id + '&id=' + self._tunnel_id + '&auth=' + self._authcookie["cookie"])
async for websocket in websockets.asyncio.client.connect(self.url, proxy=self._session._proxy, process_exception=util._process_websocket_exception, **options):
async for websocket in util.proxy_connect(self.url, proxy_url=self._session._proxy, process_exception=util._process_websocket_exception, **options):
self.alive = True
self._socket_open.set()
try:

View File

@@ -11,6 +11,7 @@ import ssl
import functools
import urllib
import python_socks
from python_socks.async_.asyncio import Proxy
from . import exceptions
def _encode_cookie(o, key):
@@ -163,7 +164,17 @@ def _process_websocket_exception(exc):
return exc
if isinstance(exc, python_socks._errors.ProxyError):
return None
# Proxy errors show up like this now, and it's default to error out. Handle explicitly.
if isinstance(exc, websockets.exceptions.InvalidProxyMessage):
return None
return tmp
return tmp
class proxy_connect(websockets.asyncio.client.connect):
def __init__(self,*args, proxy_url=None, **kwargs):
self.proxy = None
if proxy_url is not None:
self.proxy = Proxy.from_url(proxy_url)
super().__init__(*args, **kwargs)
async def create_connection(self, *args, **kwargs):
if self.proxy is not None:
parsed = urllib.parse.urlparse(self.uri)
self.connection_kwargs["sock"] = await self.proxy.connect(dest_host=parsed.hostname, dest_port=parsed.port)
return await super().create_connection(*args, **kwargs)

View File

@@ -3,4 +3,4 @@ pytest-asyncio
cffi==1.17.1
cryptography~=44.0.1
pycparser==2.22
websockets~=15.0.0
websockets~=14.2

View File

@@ -46,11 +46,9 @@ async def test_auto_reconnect(env):
for i in range(3):
try:
await admin_session.ping(timeout=10)
except* Exception as e:
print("".join(traceback.format_exception(e)))
pass
else:
break
except:
continue
break
else:
raise Exception("Failed to reconnect")
@@ -59,7 +57,6 @@ async def test_auto_reconnect(env):
try:
await admin_session.ping(timeout=10)
except* Exception as e:
print("".join(traceback.format_exception(e)))
pass
else:
break