mirror of
https://github.com/HuFlungDu/pylibmeshctrl.git
synced 2026-02-20 13:42:11 +00:00
Compare commits
6 Commits
1.1.2
...
feat/webso
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcf523dd62 | ||
|
|
9a1311167d | ||
|
|
c2319fcf29 | ||
|
|
4d1c25a35c | ||
|
|
f8600b09fe | ||
|
|
61eebf1532 |
@@ -8,5 +8,5 @@ sphinx-toolbox>=2.16.0
|
|||||||
cffi~=1.17.1
|
cffi~=1.17.1
|
||||||
cryptography~=44.0.1
|
cryptography~=44.0.1
|
||||||
pycparser~=2.22
|
pycparser~=2.22
|
||||||
websockets~=14.2
|
websockets~=15.0.0
|
||||||
enum_tools
|
enum_tools
|
||||||
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
@@ -45,7 +45,7 @@ python_requires = >=3.8
|
|||||||
install_requires =
|
install_requires =
|
||||||
importlib-metadata
|
importlib-metadata
|
||||||
cryptography~=44.0.1
|
cryptography~=44.0.1
|
||||||
websockets~=14.2
|
websockets~=15.0.0
|
||||||
python-socks[asyncio]~=2.5.3
|
python-socks[asyncio]~=2.5.3
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ class Session(object):
|
|||||||
|
|
||||||
|
|
||||||
options["additional_headers"] = headers
|
options["additional_headers"] = headers
|
||||||
async for websocket in util.proxy_connect(self.url, proxy_url=self._proxy, process_exception=util._process_websocket_exception, **options):
|
async for websocket in websockets.asyncio.client.connect(self.url, proxy=self._proxy, process_exception=util._process_websocket_exception, **options):
|
||||||
self.alive = True
|
self.alive = True
|
||||||
self._socket_open.set()
|
self._socket_open.set()
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -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"])
|
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 util.proxy_connect(self.url, proxy_url=self._session._proxy, process_exception=util._process_websocket_exception, **options):
|
async for websocket in websockets.asyncio.client.connect(self.url, proxy=self._session._proxy, process_exception=util._process_websocket_exception, **options):
|
||||||
self.alive = True
|
self.alive = True
|
||||||
self._socket_open.set()
|
self._socket_open.set()
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import ssl
|
|||||||
import functools
|
import functools
|
||||||
import urllib
|
import urllib
|
||||||
import python_socks
|
import python_socks
|
||||||
from python_socks.async_.asyncio import Proxy
|
|
||||||
from . import exceptions
|
from . import exceptions
|
||||||
|
|
||||||
def _encode_cookie(o, key):
|
def _encode_cookie(o, key):
|
||||||
@@ -164,17 +163,7 @@ def _process_websocket_exception(exc):
|
|||||||
return exc
|
return exc
|
||||||
if isinstance(exc, python_socks._errors.ProxyError):
|
if isinstance(exc, python_socks._errors.ProxyError):
|
||||||
return None
|
return None
|
||||||
return tmp
|
# Proxy errors show up like this now, and it's default to error out. Handle explicitly.
|
||||||
|
if isinstance(exc, websockets.exceptions.InvalidProxyMessage):
|
||||||
class proxy_connect(websockets.asyncio.client.connect):
|
return None
|
||||||
def __init__(self,*args, proxy_url=None, **kwargs):
|
return tmp
|
||||||
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)
|
|
||||||
@@ -3,4 +3,4 @@ pytest-asyncio
|
|||||||
cffi==1.17.1
|
cffi==1.17.1
|
||||||
cryptography~=44.0.1
|
cryptography~=44.0.1
|
||||||
pycparser==2.22
|
pycparser==2.22
|
||||||
websockets~=14.2
|
websockets~=15.0.0
|
||||||
@@ -46,9 +46,11 @@ async def test_auto_reconnect(env):
|
|||||||
for i in range(3):
|
for i in range(3):
|
||||||
try:
|
try:
|
||||||
await admin_session.ping(timeout=10)
|
await admin_session.ping(timeout=10)
|
||||||
except:
|
except* Exception as e:
|
||||||
continue
|
print("".join(traceback.format_exception(e)))
|
||||||
break
|
pass
|
||||||
|
else:
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
raise Exception("Failed to reconnect")
|
raise Exception("Failed to reconnect")
|
||||||
|
|
||||||
@@ -57,6 +59,7 @@ async def test_auto_reconnect(env):
|
|||||||
try:
|
try:
|
||||||
await admin_session.ping(timeout=10)
|
await admin_session.ping(timeout=10)
|
||||||
except* Exception as e:
|
except* Exception as e:
|
||||||
|
print("".join(traceback.format_exception(e)))
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user