wisp-python 0.8.4__tar.gz → 0.9.1__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.
Files changed (21) hide show
  1. {wisp_python-0.8.4/src/wisp_python.egg-info → wisp_python-0.9.1}/PKG-INFO +2 -2
  2. {wisp_python-0.8.4 → wisp_python-0.9.1}/pyproject.toml +2 -2
  3. {wisp_python-0.8.4 → wisp_python-0.9.1}/src/wisp/server/cli.py +2 -0
  4. {wisp_python-0.8.4 → wisp_python-0.9.1}/src/wisp/server/http.py +59 -4
  5. wisp_python-0.9.1/src/wisp/server/warp.py +0 -0
  6. {wisp_python-0.8.4 → wisp_python-0.9.1/src/wisp_python.egg-info}/PKG-INFO +2 -2
  7. {wisp_python-0.8.4 → wisp_python-0.9.1}/src/wisp_python.egg-info/SOURCES.txt +1 -0
  8. {wisp_python-0.8.4 → wisp_python-0.9.1}/LICENSE +0 -0
  9. {wisp_python-0.8.4 → wisp_python-0.9.1}/LICENSE_third_party.md +0 -0
  10. {wisp_python-0.8.4 → wisp_python-0.9.1}/README.md +0 -0
  11. {wisp_python-0.8.4 → wisp_python-0.9.1}/setup.cfg +0 -0
  12. {wisp_python-0.8.4 → wisp_python-0.9.1}/src/wisp/__init__.py +0 -0
  13. {wisp_python-0.8.4 → wisp_python-0.9.1}/src/wisp/server/__init__.py +0 -0
  14. {wisp_python-0.8.4 → wisp_python-0.9.1}/src/wisp/server/__main__.py +0 -0
  15. {wisp_python-0.8.4 → wisp_python-0.9.1}/src/wisp/server/connection.py +0 -0
  16. {wisp_python-0.8.4 → wisp_python-0.9.1}/src/wisp/server/net.py +0 -0
  17. {wisp_python-0.8.4 → wisp_python-0.9.1}/src/wisp/server/ratelimit.py +0 -0
  18. {wisp_python-0.8.4 → wisp_python-0.9.1}/src/wisp/util.py +0 -0
  19. {wisp_python-0.8.4 → wisp_python-0.9.1}/src/wisp_python.egg-info/dependency_links.txt +0 -0
  20. {wisp_python-0.8.4 → wisp_python-0.9.1}/src/wisp_python.egg-info/requires.txt +0 -0
  21. {wisp_python-0.8.4 → wisp_python-0.9.1}/src/wisp_python.egg-info/top_level.txt +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wisp-python
3
- Version: 0.8.4
3
+ Version: 0.9.1
4
4
  Summary: An implementation of a Wisp proxy server in Python
5
5
  Author: ading2210
6
+ License-Expression: AGPL-3.0-or-later
6
7
  Project-URL: Homepage, https://github.com/MercuryWorkshop/wisp-server-python
7
8
  Project-URL: Issues, https://github.com/MercuryWorkshop/wisp-server-python/issues
8
9
  Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: GNU Affero General Public License v3
10
10
  Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.9
12
12
  Description-Content-Type: text/markdown
@@ -11,7 +11,8 @@ package-dir = {"" = "src"}
11
11
 
12
12
  [project]
13
13
  name = "wisp-python"
14
- version = "0.8.4"
14
+ version = "0.9.1"
15
+ license = "AGPL-3.0-or-later"
15
16
  authors = [
16
17
  {name="ading2210"},
17
18
  ]
@@ -20,7 +21,6 @@ readme = "README.md"
20
21
  requires-python = ">=3.9"
21
22
  classifiers = [
22
23
  "Programming Language :: Python :: 3",
23
- "License :: OSI Approved :: GNU Affero General Public License v3",
24
24
  "Operating System :: OS Independent",
25
25
  ]
26
26
  dependencies = [
@@ -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,58 @@ 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
+ <meta name="robots" content="noindex">
23
+ <title>wisp-server-python v{wisp.version}</title>
24
+ <style>
25
+ html {{
26
+ color-scheme: light dark;
27
+ }}
28
+ h1, p {{
29
+ font-family: sans-serif;
30
+ }}
31
+ body {{
32
+ max-width: 600px;
33
+ margin-left: auto;
34
+ margin-right: auto;
35
+ }}
36
+ pre {{
37
+ white-space: pre-wrap
38
+ }}
39
+ </style>
40
+ </head>
41
+ <body>
42
+ <h1>wisp-server-python</h1>
43
+ <p>This is a <a href="https://github.com/MercuryWorkshop/wisp-protocol">Wisp protocol</a> server running
44
+ <a href="https://github.com/MercuryWorkshop/wisp-server-python">wisp-server-python</a> v{wisp.version}.</p>
45
+ <p>This program is licensed under the <a href="https://github.com/MercuryWorkshop/wisp-server-python/blob/main/LICENSE">GNU AGPL v3</a>.</p>
46
+ <pre>
47
+ wisp-server-python: a Wisp server implementation written in Python
48
+ Copyright (C) 2025 Mercury Workshop
49
+
50
+ This program is free software: you can redistribute it and/or modify
51
+ it under the terms of the GNU Affero General Public License as published by
52
+ the Free Software Foundation, either version 3 of the License, or
53
+ (at your option) any later version.
54
+
55
+ This program is distributed in the hope that it will be useful,
56
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
57
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58
+ GNU Affero General Public License for more details.
59
+
60
+ You should have received a copy of the GNU Affero General Public License
61
+ along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
62
+ </pre>
63
+ </body>
64
+ </html>
65
+ """.strip()
66
+
14
67
  async def connection_handler(websocket, path):
15
68
  client_ip = websocket.remote_address[0]
16
69
  if client_ip == "127.0.0.1" and "X-Real-IP" in websocket.request_headers:
@@ -37,9 +90,14 @@ async def connection_handler(websocket, path):
37
90
  tcp_handler = asyncio.create_task(wsproxy_conn.handle_tcp())
38
91
  await asyncio.gather(ws_handler, tcp_handler)
39
92
 
40
- async def static_handler(path, request_headers):
93
+ async def request_handler(path, request_headers):
41
94
  if "Upgrade" in request_headers:
42
95
  return
96
+ if not static_path:
97
+ if path.endswith("/") or path.endswith("/index.html"):
98
+ return 200, [("Content-Type", "text/html")], default_html.encode()
99
+ else:
100
+ return 404, [], "404 not found".encode()
43
101
 
44
102
  response_headers = []
45
103
  target_path = static_path / path[1:]
@@ -62,10 +120,7 @@ async def main(args):
62
120
 
63
121
  if args.static:
64
122
  static_path = pathlib.Path(args.static).resolve()
65
- request_handler = static_handler
66
123
  mimetypes.init()
67
- else:
68
- request_handler = None
69
124
 
70
125
  if args.limits:
71
126
  ratelimit.enabled = True
File without changes
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wisp-python
3
- Version: 0.8.4
3
+ Version: 0.9.1
4
4
  Summary: An implementation of a Wisp proxy server in Python
5
5
  Author: ading2210
6
+ License-Expression: AGPL-3.0-or-later
6
7
  Project-URL: Homepage, https://github.com/MercuryWorkshop/wisp-server-python
7
8
  Project-URL: Issues, https://github.com/MercuryWorkshop/wisp-server-python/issues
8
9
  Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: GNU Affero General Public License v3
10
10
  Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.9
12
12
  Description-Content-Type: text/markdown
@@ -11,6 +11,7 @@ src/wisp/server/connection.py
11
11
  src/wisp/server/http.py
12
12
  src/wisp/server/net.py
13
13
  src/wisp/server/ratelimit.py
14
+ src/wisp/server/warp.py
14
15
  src/wisp_python.egg-info/PKG-INFO
15
16
  src/wisp_python.egg-info/SOURCES.txt
16
17
  src/wisp_python.egg-info/dependency_links.txt
File without changes
File without changes
File without changes