wisp-python 0.8.2__tar.gz → 0.8.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {wisp_python-0.8.2/src/wisp_python.egg-info → wisp_python-0.8.4}/PKG-INFO +3 -2
- {wisp_python-0.8.2 → wisp_python-0.8.4}/README.md +1 -1
- {wisp_python-0.8.2 → wisp_python-0.8.4}/pyproject.toml +3 -2
- {wisp_python-0.8.2 → wisp_python-0.8.4}/src/wisp/server/cli.py +52 -17
- {wisp_python-0.8.2 → wisp_python-0.8.4}/src/wisp/server/connection.py +2 -2
- {wisp_python-0.8.2 → wisp_python-0.8.4/src/wisp_python.egg-info}/PKG-INFO +3 -2
- {wisp_python-0.8.2 → wisp_python-0.8.4}/src/wisp_python.egg-info/requires.txt +3 -0
- {wisp_python-0.8.2 → wisp_python-0.8.4}/LICENSE +0 -0
- {wisp_python-0.8.2 → wisp_python-0.8.4}/LICENSE_third_party.md +0 -0
- {wisp_python-0.8.2 → wisp_python-0.8.4}/setup.cfg +0 -0
- {wisp_python-0.8.2 → wisp_python-0.8.4}/src/wisp/__init__.py +0 -0
- {wisp_python-0.8.2 → wisp_python-0.8.4}/src/wisp/server/__init__.py +0 -0
- {wisp_python-0.8.2 → wisp_python-0.8.4}/src/wisp/server/__main__.py +0 -0
- {wisp_python-0.8.2 → wisp_python-0.8.4}/src/wisp/server/http.py +0 -0
- {wisp_python-0.8.2 → wisp_python-0.8.4}/src/wisp/server/net.py +0 -0
- {wisp_python-0.8.2 → wisp_python-0.8.4}/src/wisp/server/ratelimit.py +0 -0
- {wisp_python-0.8.2 → wisp_python-0.8.4}/src/wisp/util.py +0 -0
- {wisp_python-0.8.2 → wisp_python-0.8.4}/src/wisp_python.egg-info/SOURCES.txt +0 -0
- {wisp_python-0.8.2 → wisp_python-0.8.4}/src/wisp_python.egg-info/dependency_links.txt +0 -0
- {wisp_python-0.8.2 → wisp_python-0.8.4}/src/wisp_python.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: wisp-python
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.4
|
|
4
4
|
Summary: An implementation of a Wisp proxy server in Python
|
|
5
5
|
Author: ading2210
|
|
6
6
|
Project-URL: Homepage, https://github.com/MercuryWorkshop/wisp-server-python
|
|
@@ -16,6 +16,7 @@ Requires-Dist: websockets
|
|
|
16
16
|
Requires-Dist: asyncudp
|
|
17
17
|
Requires-Dist: python-socks[asyncio]
|
|
18
18
|
Requires-Dist: uvloop; sys_platform != "win32" and sys_platform != "cygwin"
|
|
19
|
+
Requires-Dist: winloop; sys_platform == "win32" or sys_platform == "cygwin"
|
|
19
20
|
Dynamic: license-file
|
|
20
21
|
|
|
21
22
|
# Python Wisp Server
|
|
@@ -45,7 +46,7 @@ To start the server, run `python3 -m wisp.server`. The program accepts the follo
|
|
|
45
46
|
usage: wisp-server-python [-h] [--host HOST] [--port PORT] [--static STATIC] [--limits] [--bandwidth BANDWIDTH] [--connections CONNECTIONS] [--window WINDOW] [--allow-loopback] [--allow-private] [--log-level LOG_LEVEL]
|
|
46
47
|
[--threads THREADS] [--proxy PROXY] [--block-udp] [--block-tcp]
|
|
47
48
|
|
|
48
|
-
A Wisp server implementation, written in Python (v0.8.
|
|
49
|
+
A Wisp server implementation, written in Python (v0.8.3)
|
|
49
50
|
|
|
50
51
|
options:
|
|
51
52
|
-h, --help show this help message and exit
|
|
@@ -25,7 +25,7 @@ To start the server, run `python3 -m wisp.server`. The program accepts the follo
|
|
|
25
25
|
usage: wisp-server-python [-h] [--host HOST] [--port PORT] [--static STATIC] [--limits] [--bandwidth BANDWIDTH] [--connections CONNECTIONS] [--window WINDOW] [--allow-loopback] [--allow-private] [--log-level LOG_LEVEL]
|
|
26
26
|
[--threads THREADS] [--proxy PROXY] [--block-udp] [--block-tcp]
|
|
27
27
|
|
|
28
|
-
A Wisp server implementation, written in Python (v0.8.
|
|
28
|
+
A Wisp server implementation, written in Python (v0.8.3)
|
|
29
29
|
|
|
30
30
|
options:
|
|
31
31
|
-h, --help show this help message and exit
|
|
@@ -11,7 +11,7 @@ package-dir = {"" = "src"}
|
|
|
11
11
|
|
|
12
12
|
[project]
|
|
13
13
|
name = "wisp-python"
|
|
14
|
-
version = "0.8.
|
|
14
|
+
version = "0.8.4"
|
|
15
15
|
authors = [
|
|
16
16
|
{name="ading2210"},
|
|
17
17
|
]
|
|
@@ -27,7 +27,8 @@ dependencies = [
|
|
|
27
27
|
"websockets",
|
|
28
28
|
"asyncudp",
|
|
29
29
|
"python-socks[asyncio]",
|
|
30
|
-
"uvloop; sys_platform != 'win32' and sys_platform != 'cygwin'"
|
|
30
|
+
"uvloop; sys_platform != 'win32' and sys_platform != 'cygwin'",
|
|
31
|
+
"winloop; sys_platform == 'win32' or sys_platform == 'cygwin'"
|
|
31
32
|
]
|
|
32
33
|
|
|
33
34
|
[project.urls]
|
|
@@ -4,12 +4,23 @@ import pathlib
|
|
|
4
4
|
import sys
|
|
5
5
|
import logging
|
|
6
6
|
import multiprocessing
|
|
7
|
+
import threading
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
import concurrent.interpreters
|
|
11
|
+
has_subinterpreters = True
|
|
12
|
+
except ImportError:
|
|
13
|
+
has_subinterpreters = False
|
|
7
14
|
|
|
8
15
|
try:
|
|
9
16
|
import uvloop
|
|
10
|
-
|
|
17
|
+
event_loop = "uvloop"
|
|
11
18
|
except ImportError:
|
|
12
|
-
|
|
19
|
+
try:
|
|
20
|
+
import winloop
|
|
21
|
+
event_loop = "winloop"
|
|
22
|
+
except ImportError:
|
|
23
|
+
event_loop = "asyncio"
|
|
13
24
|
|
|
14
25
|
import wisp
|
|
15
26
|
from wisp.server import http
|
|
@@ -17,12 +28,11 @@ from wisp.server import net
|
|
|
17
28
|
|
|
18
29
|
def run_async(func, *args, **kwargs):
|
|
19
30
|
try:
|
|
20
|
-
if
|
|
31
|
+
if event_loop == "uvloop":
|
|
21
32
|
uvloop.run(func(*args, **kwargs))
|
|
33
|
+
elif event_loop == "winloop":
|
|
34
|
+
winloop.run(func(*args, **kwargs))
|
|
22
35
|
else:
|
|
23
|
-
#uvloop doesn't support windows at all so we don't need to print the error
|
|
24
|
-
if not sys.platform in ("win32", "cygwin"):
|
|
25
|
-
logging.error("Importing uvloop failed. Falling back to asyncio, which is slower.")
|
|
26
36
|
asyncio.run(func(*args, **kwargs))
|
|
27
37
|
except KeyboardInterrupt:
|
|
28
38
|
pass
|
|
@@ -30,6 +40,34 @@ def run_async(func, *args, **kwargs):
|
|
|
30
40
|
def run_http(args):
|
|
31
41
|
run_async(http.main, args)
|
|
32
42
|
|
|
43
|
+
def run_processes(thread_count, args):
|
|
44
|
+
processes = []
|
|
45
|
+
for i in range(0, int(thread_count)):
|
|
46
|
+
process = multiprocessing.Process(target=run_http, args=(args,), daemon=True)
|
|
47
|
+
processes.append(process)
|
|
48
|
+
process.start()
|
|
49
|
+
try:
|
|
50
|
+
for process in processes:
|
|
51
|
+
process.join()
|
|
52
|
+
except KeyboardInterrupt:
|
|
53
|
+
pass
|
|
54
|
+
|
|
55
|
+
def run_subinterpreters(thread_count, args):
|
|
56
|
+
def thread_func():
|
|
57
|
+
interpreter = concurrent.interpreters.create()
|
|
58
|
+
interpreter.call(run_http, args)
|
|
59
|
+
|
|
60
|
+
threads = []
|
|
61
|
+
for i in range(0, int(thread_count)):
|
|
62
|
+
thread = threading.Thread(target=thread_func, daemon=True)
|
|
63
|
+
threads.append(thread)
|
|
64
|
+
thread.start()
|
|
65
|
+
try:
|
|
66
|
+
for thread in threads:
|
|
67
|
+
thread.join()
|
|
68
|
+
except KeyboardInterrupt:
|
|
69
|
+
pass
|
|
70
|
+
|
|
33
71
|
def main():
|
|
34
72
|
parser = argparse.ArgumentParser(
|
|
35
73
|
prog="wisp-server-python",
|
|
@@ -68,22 +106,19 @@ def main():
|
|
|
68
106
|
logging.info(f"proxy enabled: {args.proxy}")
|
|
69
107
|
logging.info(f"listening on {args.host}:{args.port}")
|
|
70
108
|
|
|
109
|
+
if event_loop == "asyncio":
|
|
110
|
+
logging.error("failed to import uvloop or winloop. falling back to asyncio, which is slower.")
|
|
111
|
+
|
|
71
112
|
threads = int(args.threads)
|
|
72
113
|
if net.reuse_port_supported():
|
|
73
114
|
if threads == 0:
|
|
74
115
|
threads = multiprocessing.cpu_count()
|
|
75
116
|
logging.info(f"running using {threads} threads")
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
process.start()
|
|
82
|
-
try:
|
|
83
|
-
for process in processes:
|
|
84
|
-
process.join()
|
|
85
|
-
except KeyboardInterrupt:
|
|
86
|
-
pass
|
|
117
|
+
|
|
118
|
+
if has_subinterpreters:
|
|
119
|
+
run_subinterpreters(threads, args);
|
|
120
|
+
else:
|
|
121
|
+
run_processes(threads, args)
|
|
87
122
|
|
|
88
123
|
else:
|
|
89
124
|
if threads != 0:
|
|
@@ -118,8 +118,8 @@ class WispConnection:
|
|
|
118
118
|
|
|
119
119
|
async def stream_ws_to_tcp(self, stream_id):
|
|
120
120
|
#this infinite loop should get killed by the task.cancel call later on
|
|
121
|
+
stream = self.active_streams[stream_id]
|
|
121
122
|
while True:
|
|
122
|
-
stream = self.active_streams[stream_id]
|
|
123
123
|
data = await stream["queue"].get()
|
|
124
124
|
try:
|
|
125
125
|
await stream["conn"].send(data)
|
|
@@ -135,8 +135,8 @@ class WispConnection:
|
|
|
135
135
|
await self.ws.send(continue_packet)
|
|
136
136
|
|
|
137
137
|
async def stream_tcp_to_ws(self, stream_id):
|
|
138
|
+
stream = self.active_streams[stream_id]
|
|
138
139
|
while True:
|
|
139
|
-
stream = self.active_streams[stream_id]
|
|
140
140
|
try:
|
|
141
141
|
data = await stream["conn"].recv()
|
|
142
142
|
except Exception as e:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: wisp-python
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.4
|
|
4
4
|
Summary: An implementation of a Wisp proxy server in Python
|
|
5
5
|
Author: ading2210
|
|
6
6
|
Project-URL: Homepage, https://github.com/MercuryWorkshop/wisp-server-python
|
|
@@ -16,6 +16,7 @@ Requires-Dist: websockets
|
|
|
16
16
|
Requires-Dist: asyncudp
|
|
17
17
|
Requires-Dist: python-socks[asyncio]
|
|
18
18
|
Requires-Dist: uvloop; sys_platform != "win32" and sys_platform != "cygwin"
|
|
19
|
+
Requires-Dist: winloop; sys_platform == "win32" or sys_platform == "cygwin"
|
|
19
20
|
Dynamic: license-file
|
|
20
21
|
|
|
21
22
|
# Python Wisp Server
|
|
@@ -45,7 +46,7 @@ To start the server, run `python3 -m wisp.server`. The program accepts the follo
|
|
|
45
46
|
usage: wisp-server-python [-h] [--host HOST] [--port PORT] [--static STATIC] [--limits] [--bandwidth BANDWIDTH] [--connections CONNECTIONS] [--window WINDOW] [--allow-loopback] [--allow-private] [--log-level LOG_LEVEL]
|
|
46
47
|
[--threads THREADS] [--proxy PROXY] [--block-udp] [--block-tcp]
|
|
47
48
|
|
|
48
|
-
A Wisp server implementation, written in Python (v0.8.
|
|
49
|
+
A Wisp server implementation, written in Python (v0.8.3)
|
|
49
50
|
|
|
50
51
|
options:
|
|
51
52
|
-h, --help show this help message and exit
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|