wisp-python 0.9.1__py3-none-any.whl → 0.10.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
@@ -23,6 +23,12 @@ except ImportError:
23
23
  except ImportError:
24
24
  event_loop = "asyncio"
25
25
 
26
+ try:
27
+ import pymasque
28
+ has_pymasque = True
29
+ except ImportError:
30
+ has_pymasque = False
31
+
26
32
  import wisp
27
33
  from wisp.server import http
28
34
  from wisp.server import net
@@ -86,7 +92,7 @@ def main():
86
92
  parser.add_argument("--allow-private", action="store_true", help="Allow connections to private IP addresses.")
87
93
  parser.add_argument("--log-level", default="info", help="The log level (either debug, info, warning, error, or critical).")
88
94
  parser.add_argument("--threads", default=0, help="The number of threads to run the server on. By default it uses all CPU cores. (Linux only)")
89
- parser.add_argument("--proxy", default=None, help="The url of the socks5h, socks5, sock4a, socks4 or http proxy to use.")
95
+ parser.add_argument("--proxy", default=None, help="The url of the socks5h, socks5, sock4a, socks4 or http proxy to use. Set this to 'warp' to use Cloudflare Warp as a proxy.")
90
96
  parser.add_argument("--block-udp", action="store_true", help="Block UDP streams.")
91
97
  parser.add_argument("--block-tcp", action="store_true", help="Block TCP streams.")
92
98
  args = parser.parse_args()
@@ -96,8 +102,10 @@ def main():
96
102
  level=getattr(logging, args.log_level.upper()),
97
103
  datefmt="%Y/%m/%d - %H:%M:%S"
98
104
  )
99
-
100
105
  logging.info(f"running wisp-server-python v{wisp.version} (async)")
106
+
107
+ if args.proxy and args.proxy == "warp" and has_pymasque == False:
108
+ raise ImportError("warp proxy was selected by pymasque is not installed. run 'pip install wisp-python[warp]' to install it")
101
109
  if args.static:
102
110
  static_path = pathlib.Path(args.static).resolve()
103
111
  logging.info(f"serving static files from {static_path}")
wisp/server/net.py CHANGED
@@ -4,6 +4,10 @@ import ipaddress
4
4
 
5
5
  import asyncudp
6
6
  from python_socks.async_.asyncio import Proxy
7
+ try:
8
+ import pymasque
9
+ except ImportError:
10
+ pass
7
11
 
8
12
  #various network utilities and wrappers
9
13
 
@@ -15,6 +19,7 @@ block_tcp = False
15
19
 
16
20
  proxy_url = None
17
21
  proxy_dns = False
22
+ warp = None
18
23
 
19
24
  def reuse_port_supported():
20
25
  return hasattr(socket, "SO_REUSEPORT")
@@ -69,7 +74,14 @@ class TCPConnection:
69
74
  raise TypeError("TCP connection blocked.")
70
75
 
71
76
  addr_str = await validate_hostname(self.hostname, self.port, 0x01)
72
- if proxy_url:
77
+ if proxy_url == "warp":
78
+ global warp
79
+ if warp is None:
80
+ warp = pymasque.WarpConnection()
81
+ stream = await warp.open_stream(self.hostname, self.port)
82
+ await stream.ensure_response()
83
+ self.tcp_reader, self.tcp_writer = stream, stream
84
+ elif proxy_url:
73
85
  proxy = Proxy.from_url(proxy_url, rdns=proxy_dns)
74
86
  proxy_dest = self.hostname if proxy_dns else addr_str
75
87
  sock = await proxy.connect(dest_host=proxy_dest, dest_port=self.port)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wisp-python
3
- Version: 0.9.1
3
+ Version: 0.10.0
4
4
  Summary: An implementation of a Wisp proxy server in Python
5
5
  Author: ading2210
6
6
  License-Expression: AGPL-3.0-or-later
@@ -17,6 +17,8 @@ Requires-Dist: asyncudp
17
17
  Requires-Dist: python-socks[asyncio]
18
18
  Requires-Dist: uvloop; sys_platform != "win32" and sys_platform != "cygwin"
19
19
  Requires-Dist: winloop; sys_platform == "win32" or sys_platform == "cygwin"
20
+ Provides-Extra: warp
21
+ Requires-Dist: pymasque; extra == "warp"
20
22
  Dynamic: license-file
21
23
 
22
24
  # Python Wisp Server
@@ -38,15 +40,21 @@ Run the following command to install this program:
38
40
  pip3 install wisp-python
39
41
  ```
40
42
 
43
+ To install the Cloudflare Warp proxy feature:
44
+ ```
45
+ pip3 install wisp-python[warp]
46
+ ```
47
+ This allows you proxy all exit traffic through Cloudflare Warp.
48
+
41
49
  ## Running the Server:
42
50
  For the best performance use [CPython](https://github.com/python/cpython) 3.11 or newer. [PyPy](https://github.com/pypy/pypy) is not recommended as it is a lot slower than CPython here.
43
51
 
44
52
  To start the server, run `python3 -m wisp.server`. The program accepts the following arguments:
45
53
  ```
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]
47
- [--threads THREADS] [--proxy PROXY] [--block-udp] [--block-tcp]
54
+ 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] [--threads THREADS] [--proxy PROXY]
55
+ [--block-udp] [--block-tcp]
48
56
 
49
- A Wisp server implementation, written in Python (v0.8.3)
57
+ A Wisp server implementation, written in Python (v0.10.0)
50
58
 
51
59
  options:
52
60
  -h, --help show this help message and exit
@@ -64,7 +72,7 @@ options:
64
72
  --log-level LOG_LEVEL
65
73
  The log level (either debug, info, warning, error, or critical).
66
74
  --threads THREADS The number of threads to run the server on. By default it uses all CPU cores. (Linux only)
67
- --proxy PROXY The url of the socks5h, socks5, sock4a, socks4 or http proxy to use.
75
+ --proxy PROXY The url of the socks5h, socks5, sock4a, socks4 or http proxy to use. Set this to 'warp' to use Cloudflare Warp as a proxy.
68
76
  --block-udp Block UDP streams.
69
77
  --block-tcp Block TCP streams.
70
78
  ```
@@ -0,0 +1,15 @@
1
+ wisp/__init__.py,sha256=02Fv0s_jJG8U4y5B6AzKPIOzxAuqJyY_So8Guz5bdTk,75
2
+ wisp/util.py,sha256=AU7si8VwJqS8Dwc1PT2pu_f_9Y32GQxivRYwJ3-U0YQ,144
3
+ wisp/server/__init__.py,sha256=LmgQ1nTlnqcTPqRJVc1NGapV9qVR-BK8iPVUMSJ74Qs,102
4
+ wisp/server/__main__.py,sha256=zhDqmhOY9HgHx-BOq-kU5IoxZCMJwt_PEEEISaZr9Mk,68
5
+ wisp/server/cli.py,sha256=W-jeyltr_ynwZ32jqyD43Si5OWRVd8sqAO2GdD39Das,4748
6
+ wisp/server/connection.py,sha256=0ztt3TejF0fY3eXtkTn9QozOj0_x-KOPC4vXberUsrQ,7665
7
+ wisp/server/http.py,sha256=DqmXTDkomHeVz0EkJhb1PujAAWwl45BwMW00bpEBfGA,5382
8
+ wisp/server/net.py,sha256=C0A0xB1jyMfTR3PeDw2Oo7guGSQE93Xa2_yKof6z21M,3693
9
+ wisp/server/ratelimit.py,sha256=cic_rlBaM-tp6kJaSz4ITGvUbsX4JLSGSUgF5cPO0FY,1926
10
+ wisp_python-0.10.0.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
11
+ wisp_python-0.10.0.dist-info/licenses/LICENSE_third_party.md,sha256=_YgCpygAXxOtr7gpjRTv7W1DTqZU_f7IMwjdPvw4VxY,15360
12
+ wisp_python-0.10.0.dist-info/METADATA,sha256=s2qcZpwom4YQ_4ABunp9ckJwkbgYOdPzoOnAX8SMd8s,4490
13
+ wisp_python-0.10.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
14
+ wisp_python-0.10.0.dist-info/top_level.txt,sha256=sv0LDAu8cHUc3_VTsCKfXU-6B9HdV4dW22ubeW8KPVs,5
15
+ wisp_python-0.10.0.dist-info/RECORD,,
wisp/server/warp.py DELETED
File without changes
@@ -1,16 +0,0 @@
1
- wisp/__init__.py,sha256=02Fv0s_jJG8U4y5B6AzKPIOzxAuqJyY_So8Guz5bdTk,75
2
- wisp/util.py,sha256=AU7si8VwJqS8Dwc1PT2pu_f_9Y32GQxivRYwJ3-U0YQ,144
3
- wisp/server/__init__.py,sha256=LmgQ1nTlnqcTPqRJVc1NGapV9qVR-BK8iPVUMSJ74Qs,102
4
- wisp/server/__main__.py,sha256=zhDqmhOY9HgHx-BOq-kU5IoxZCMJwt_PEEEISaZr9Mk,68
5
- wisp/server/cli.py,sha256=pkpl_ojw_M3QH4FlTlBe5QQh17brgYS86fQJA_9ks-o,4408
6
- wisp/server/connection.py,sha256=0ztt3TejF0fY3eXtkTn9QozOj0_x-KOPC4vXberUsrQ,7665
7
- wisp/server/http.py,sha256=DqmXTDkomHeVz0EkJhb1PujAAWwl45BwMW00bpEBfGA,5382
8
- wisp/server/net.py,sha256=_Uxv9w1DCCcJO7VaSOfxQhM5PYpwrYm3Hd1XDQ5F_n8,3362
9
- wisp/server/ratelimit.py,sha256=cic_rlBaM-tp6kJaSz4ITGvUbsX4JLSGSUgF5cPO0FY,1926
10
- wisp/server/warp.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- wisp_python-0.9.1.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
12
- wisp_python-0.9.1.dist-info/licenses/LICENSE_third_party.md,sha256=_YgCpygAXxOtr7gpjRTv7W1DTqZU_f7IMwjdPvw4VxY,15360
13
- wisp_python-0.9.1.dist-info/METADATA,sha256=W3l_SgClI14BVruksufTzL2fJmU7ETAeWGo4Llv6JSY,4222
14
- wisp_python-0.9.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
15
- wisp_python-0.9.1.dist-info/top_level.txt,sha256=sv0LDAu8cHUc3_VTsCKfXU-6B9HdV4dW22ubeW8KPVs,5
16
- wisp_python-0.9.1.dist-info/RECORD,,