wisp-python 0.8.4__tar.gz → 0.9.0__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.4/src/wisp_python.egg-info → wisp_python-0.9.0}/PKG-INFO +1 -1
- {wisp_python-0.8.4 → wisp_python-0.9.0}/pyproject.toml +1 -1
- {wisp_python-0.8.4 → wisp_python-0.9.0}/src/wisp/server/cli.py +2 -0
- {wisp_python-0.8.4 → wisp_python-0.9.0}/src/wisp/server/http.py +58 -4
- {wisp_python-0.8.4 → wisp_python-0.9.0/src/wisp_python.egg-info}/PKG-INFO +1 -1
- {wisp_python-0.8.4 → wisp_python-0.9.0}/LICENSE +0 -0
- {wisp_python-0.8.4 → wisp_python-0.9.0}/LICENSE_third_party.md +0 -0
- {wisp_python-0.8.4 → wisp_python-0.9.0}/README.md +0 -0
- {wisp_python-0.8.4 → wisp_python-0.9.0}/setup.cfg +0 -0
- {wisp_python-0.8.4 → wisp_python-0.9.0}/src/wisp/__init__.py +0 -0
- {wisp_python-0.8.4 → wisp_python-0.9.0}/src/wisp/server/__init__.py +0 -0
- {wisp_python-0.8.4 → wisp_python-0.9.0}/src/wisp/server/__main__.py +0 -0
- {wisp_python-0.8.4 → wisp_python-0.9.0}/src/wisp/server/connection.py +0 -0
- {wisp_python-0.8.4 → wisp_python-0.9.0}/src/wisp/server/net.py +0 -0
- {wisp_python-0.8.4 → wisp_python-0.9.0}/src/wisp/server/ratelimit.py +0 -0
- {wisp_python-0.8.4 → wisp_python-0.9.0}/src/wisp/util.py +0 -0
- {wisp_python-0.8.4 → wisp_python-0.9.0}/src/wisp_python.egg-info/SOURCES.txt +0 -0
- {wisp_python-0.8.4 → wisp_python-0.9.0}/src/wisp_python.egg-info/dependency_links.txt +0 -0
- {wisp_python-0.8.4 → wisp_python-0.9.0}/src/wisp_python.egg-info/requires.txt +0 -0
- {wisp_python-0.8.4 → wisp_python-0.9.0}/src/wisp_python.egg-info/top_level.txt +0 -0
|
@@ -5,6 +5,7 @@ import sys
|
|
|
5
5
|
import logging
|
|
6
6
|
import multiprocessing
|
|
7
7
|
import threading
|
|
8
|
+
import platform
|
|
8
9
|
|
|
9
10
|
try:
|
|
10
11
|
import concurrent.interpreters
|
|
@@ -104,6 +105,7 @@ def main():
|
|
|
104
105
|
logging.info("enabled rate limits")
|
|
105
106
|
if args.proxy:
|
|
106
107
|
logging.info(f"proxy enabled: {args.proxy}")
|
|
108
|
+
logging.info(f"running on {platform.python_implementation()} {platform.python_version()}")
|
|
107
109
|
logging.info(f"listening on {args.host}:{args.port}")
|
|
108
110
|
|
|
109
111
|
if event_loop == "asyncio":
|
|
@@ -3,6 +3,7 @@ import pathlib
|
|
|
3
3
|
import mimetypes
|
|
4
4
|
import logging
|
|
5
5
|
import random
|
|
6
|
+
import textwrap
|
|
6
7
|
|
|
7
8
|
from websockets.server import serve
|
|
8
9
|
|
|
@@ -11,6 +12,57 @@ from wisp.server import connection
|
|
|
11
12
|
from wisp.server import ratelimit
|
|
12
13
|
from wisp.server import net
|
|
13
14
|
|
|
15
|
+
static_path = None
|
|
16
|
+
default_html = f"""
|
|
17
|
+
<!DOCTYPE html>
|
|
18
|
+
<html lang="en">
|
|
19
|
+
<head>
|
|
20
|
+
<meta charset="utf-8">
|
|
21
|
+
<meta name="viewport" content="width=device-width">
|
|
22
|
+
<title>wisp-server-python v{wisp.version}</title>
|
|
23
|
+
<style>
|
|
24
|
+
html {{
|
|
25
|
+
color-scheme: light dark;
|
|
26
|
+
}}
|
|
27
|
+
h1, p {{
|
|
28
|
+
font-family: sans-serif;
|
|
29
|
+
}}
|
|
30
|
+
body {{
|
|
31
|
+
max-width: 600px;
|
|
32
|
+
margin-left: auto;
|
|
33
|
+
margin-right: auto;
|
|
34
|
+
}}
|
|
35
|
+
pre {{
|
|
36
|
+
white-space: pre-wrap
|
|
37
|
+
}}
|
|
38
|
+
</style>
|
|
39
|
+
</head>
|
|
40
|
+
<body>
|
|
41
|
+
<h1>wisp-server-python</h1>
|
|
42
|
+
<p>This is a <a href="https://github.com/MercuryWorkshop/wisp-protocol">Wisp protocol</a> server running
|
|
43
|
+
<a href="https://github.com/MercuryWorkshop/wisp-server-python">wisp-server-python</a> v{wisp.version}.</p>
|
|
44
|
+
<p>This program is licensed under the <a href="https://github.com/MercuryWorkshop/wisp-server-python/blob/main/LICENSE">GNU AGPL v3</a>.</p>
|
|
45
|
+
<pre>
|
|
46
|
+
wisp-server-python: a Wisp server implementation written in Python
|
|
47
|
+
Copyright (C) 2025 Mercury Workshop
|
|
48
|
+
|
|
49
|
+
This program is free software: you can redistribute it and/or modify
|
|
50
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
51
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
52
|
+
(at your option) any later version.
|
|
53
|
+
|
|
54
|
+
This program is distributed in the hope that it will be useful,
|
|
55
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
56
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
57
|
+
GNU Affero General Public License for more details.
|
|
58
|
+
|
|
59
|
+
You should have received a copy of the GNU Affero General Public License
|
|
60
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
61
|
+
</pre>
|
|
62
|
+
</body>
|
|
63
|
+
</html>
|
|
64
|
+
""".strip()
|
|
65
|
+
|
|
14
66
|
async def connection_handler(websocket, path):
|
|
15
67
|
client_ip = websocket.remote_address[0]
|
|
16
68
|
if client_ip == "127.0.0.1" and "X-Real-IP" in websocket.request_headers:
|
|
@@ -37,9 +89,14 @@ async def connection_handler(websocket, path):
|
|
|
37
89
|
tcp_handler = asyncio.create_task(wsproxy_conn.handle_tcp())
|
|
38
90
|
await asyncio.gather(ws_handler, tcp_handler)
|
|
39
91
|
|
|
40
|
-
async def
|
|
92
|
+
async def request_handler(path, request_headers):
|
|
41
93
|
if "Upgrade" in request_headers:
|
|
42
94
|
return
|
|
95
|
+
if not static_path:
|
|
96
|
+
if path.endswith("/") or path.endswith("/index.html"):
|
|
97
|
+
return 200, [("Content-Type", "text/html")], default_html.encode()
|
|
98
|
+
else:
|
|
99
|
+
return 404, [], "404 not found".encode()
|
|
43
100
|
|
|
44
101
|
response_headers = []
|
|
45
102
|
target_path = static_path / path[1:]
|
|
@@ -62,10 +119,7 @@ async def main(args):
|
|
|
62
119
|
|
|
63
120
|
if args.static:
|
|
64
121
|
static_path = pathlib.Path(args.static).resolve()
|
|
65
|
-
request_handler = static_handler
|
|
66
122
|
mimetypes.init()
|
|
67
|
-
else:
|
|
68
|
-
request_handler = None
|
|
69
123
|
|
|
70
124
|
if args.limits:
|
|
71
125
|
ratelimit.enabled = True
|
|
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
|
|
File without changes
|
|
File without changes
|