wisp-python 0.8.4__py3-none-any.whl → 0.9.0__py3-none-any.whl

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/server/cli.py CHANGED
@@ -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":
wisp/server/http.py CHANGED
@@ -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 &lt;https://www.gnu.org/licenses/&gt;.
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 static_handler(path, request_headers):
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wisp-python
3
- Version: 0.8.4
3
+ Version: 0.9.0
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
@@ -2,14 +2,14 @@ wisp/__init__.py,sha256=02Fv0s_jJG8U4y5B6AzKPIOzxAuqJyY_So8Guz5bdTk,75
2
2
  wisp/util.py,sha256=AU7si8VwJqS8Dwc1PT2pu_f_9Y32GQxivRYwJ3-U0YQ,144
3
3
  wisp/server/__init__.py,sha256=LmgQ1nTlnqcTPqRJVc1NGapV9qVR-BK8iPVUMSJ74Qs,102
4
4
  wisp/server/__main__.py,sha256=zhDqmhOY9HgHx-BOq-kU5IoxZCMJwt_PEEEISaZr9Mk,68
5
- wisp/server/cli.py,sha256=cI4zc3nAUUx24m8tQp_HRhyk9-fGwVMEtavASdQMg_g,4299
5
+ wisp/server/cli.py,sha256=pkpl_ojw_M3QH4FlTlBe5QQh17brgYS86fQJA_9ks-o,4408
6
6
  wisp/server/connection.py,sha256=0ztt3TejF0fY3eXtkTn9QozOj0_x-KOPC4vXberUsrQ,7665
7
- wisp/server/http.py,sha256=wEEpxhiodf6E4cacuRYm-WAzp7wZDqDloeESfjSSPu4,3460
7
+ wisp/server/http.py,sha256=Oq0byjMSrTHIvyQ0upNvby4Awu8S-F6C3rliE2PZ7lI,5339
8
8
  wisp/server/net.py,sha256=_Uxv9w1DCCcJO7VaSOfxQhM5PYpwrYm3Hd1XDQ5F_n8,3362
9
9
  wisp/server/ratelimit.py,sha256=cic_rlBaM-tp6kJaSz4ITGvUbsX4JLSGSUgF5cPO0FY,1926
10
- wisp_python-0.8.4.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
11
- wisp_python-0.8.4.dist-info/licenses/LICENSE_third_party.md,sha256=_YgCpygAXxOtr7gpjRTv7W1DTqZU_f7IMwjdPvw4VxY,15360
12
- wisp_python-0.8.4.dist-info/METADATA,sha256=aUQxBZvij3PSeIrlWzUGS1r7eEQ5Qa3ok2gVc7dCPc4,4260
13
- wisp_python-0.8.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
- wisp_python-0.8.4.dist-info/top_level.txt,sha256=sv0LDAu8cHUc3_VTsCKfXU-6B9HdV4dW22ubeW8KPVs,5
15
- wisp_python-0.8.4.dist-info/RECORD,,
10
+ wisp_python-0.9.0.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
11
+ wisp_python-0.9.0.dist-info/licenses/LICENSE_third_party.md,sha256=_YgCpygAXxOtr7gpjRTv7W1DTqZU_f7IMwjdPvw4VxY,15360
12
+ wisp_python-0.9.0.dist-info/METADATA,sha256=_SdbGaR4zVKLuWqpUMq2Se95VdtKxatHIb5gOONqc08,4260
13
+ wisp_python-0.9.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
+ wisp_python-0.9.0.dist-info/top_level.txt,sha256=sv0LDAu8cHUc3_VTsCKfXU-6B9HdV4dW22ubeW8KPVs,5
15
+ wisp_python-0.9.0.dist-info/RECORD,,