pymasque
pymasque is a minimal implementation of a Cloudflare Warp MASQUE client in Python, powered by qh3.
It only implements the L4 mode of the MASQUE proxy. This is faster and does not require a userspace IP stack, but only supports TCP.
Installation
Install it as a library:
pip3 install pymasque
Install it with a built-in SOCKS5 proxy:
pip3 install pymasque[socks]
Usage
SOCKS5 Proxy Mode
Use the SOCKS5 proxy mode to launch a SOCKS5 server that proxies all connections over Warp:
$ python3 -m pymasque.socks -h
usage: pymasque.socks [-h] [--host HOST] [--port PORT] [--auth AUTH] [--log-level {DEBUG,INFO,WARNING,ERROR}]
[--log-format {text,json}]
SOCKS5 proxy routing through Cloudflare WARP/MASQUE
options:
-h, --help show this help message and exit
--host HOST bind address
--port PORT bind port
--auth AUTH username:password
--log-level {DEBUG,INFO,WARNING,ERROR}
--log-format {text,json}
On first run, a new Cloudflare Warp account will be created, the details of which will be cached to the disk.
As a Library
pymasque is easy to integrate into your asyncio applications.
Basic Example:
import asyncio
import pymasque
async def main():
warp = pymasque.WarpConnection()
stream = await warp.open_stream("cloudflare.com", 80)
#send an http/1.1 payload
payload = "GET /cdn-cgi/trace HTTP/1.1\r\nHost: cloudflare.com\r\nConnection: keepalive\r\n\r\n"
await stream.send(payload.encode())
response = await stream.recv()
print(response.decode())
asyncio.run(main())
pymasque.WarpConnection and pymasque.WarpStream contain all that you need for sending TCP traffic over Cloudflare workers.
Creating New MASQUE Connections:
Creating a new pymasque.WarpConnection object and calling .connect() on it will create a new MASQUE connection to Cloudflare Warp.
You don't need to explicitly call .connect(), it will automatically run when you create the first stream.
warp = pymasque.WarpConnection()
await warp.connect()
Creating New Streams:
Streams can be created by calling WarpConnection.open_stream(hostname, port). The hostname can be any domain name, IPv4 address, or IPv6 address. If a domain name is provided, it will be resolved locally using the system DNS resolver. This will return a pymasque.WarpStream object.
warp = pymasque.WarpConnection()
stream = await warp.open_stream("example.com", 1234)
Once you have your stream object, you may call stream.recv() or stream.send(data) to recieve or send data. The data sent must be a bytes object.
await stream.send(b"hello world")
response = await stream.recv()
License
This project is licensed under the GNU LGPL v3.
This license is mainly applied to libraries. You may copy, distribute and modify the software provided that modifications are described and licensed for free under LGPL. Derivatives works (including modifications or anything statically linked to the library) can only be redistributed under LGPL, but applications that use the library don't have to be.
- From tldrlegal.com
Metadata
Release files for pymasque 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pymasque-0.1.0.tar.gz | 10.1 kB | Without provenance | Details for pymasque-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pymasque-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pymasque-0.1.0-py3-none-any.whl |
Total release size: 20.5 kB
Release files / pymasque-0.1.0.tar.gz
| Download URL | pymasque-0.1.0.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5e3be1a4134d01cdb8fc2b5b4845dc95d1e820bf6170f44c148dd7502e0e32c
|
|
BLAKE2b-256 checksum How to use checksums |
9a605ba1991a6be3d5a1ebc0adab3c0f63f05a1d82def419b02cee30cae9544c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / pymasque-0.1.0-py3-none-any.whl
| Download URL | pymasque-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f9c649212cc445966b5e3fb8b4d2c9e58dddcdeba7dfc891ab6ea4def17a9590
|
|
BLAKE2b-256 checksum How to use checksums |
05ce549319a0a644839d11b066ec46a256d9db89986866d17f14bae6dd0f7169
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for pymasque 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.