Lightweight TCP tunnel over Supabase Broadcast
Project description
SupaTunnel
Lightweight TCP tunnel over Supabase broadcast channels with AES-GCM encryption, ACK-based retransmit, and rate control.
⚙️ Features
tunnel_uuid + sidisolation keeps concurrent local connections from interfering.- AES-GCM protects payload confidentiality and integrity (secret is derived from your password). Implementation now rides on
PyCryptodome, whose wheels are prebuilt for ARM/Termux so you no longer need Rust. - ACK + timeout retransmit makes the broadcast layer behave more like a reliable stream.
- Per-session token-bucket rate limiter (
--rate-kbps). - Installable CLI (
supatunnel) viapip install -e .or registry publish.
🧱 Installation
git clone https://github.com/your-org/marx_supabase_tunnel.git
cd marx_supabase_tunnel
pip install -e .
🧩 Configuration
Export the following environment variables (see .env.example for templates) before running the CLI.
export SUPATUNNEL_URL="https://your-project.supabase.co"
export SUPATUNNEL_KEY="your-anon-key"
export SUPATUNNEL_ROOM="supa_tunnel_default"
export SUPATUNNEL_TUNNEL_UUID="7f3e9f5c-1a4d-4b2a-b3d5-2c4f9a8e1f6e"
export SUPATUNNEL_SECRET="a-strong-secret"
Optional tuning:
SUPATUNNEL_RATE_KBPS: kilobytes per second limit (default0= unlimited)SUPATUNNEL_CHUNK_BYTES: chunk size per send (default16384)SUPATUNNEL_RTO_MS: retransmit timeout (default800)SUPATUNNEL_MAX_RETRIES: retransmit attempts (default5)SUPATUNNEL_TARGET_HOST/PORT: server forwarding targetSUPATUNNEL_LISTEN_HOST/PORT: client local listen endpoint
🚀 Usage
-
Server machine (where the target service runs):
supatunnel server --target-host 127.0.0.1 --target-port 80
- Starts a Supabase broadcast listener, opens the local target, and waits for client tunnels.
-
Client machine (your access point):
supatunnel client --listen-host 127.0.0.1 --listen-port 8080
- Listens locally and forwards the traffic over Supabase using the configured tunnel ID.
- Access
http://127.0.0.1:8080to reach the remote service.
🧪 Health & debugging
supatunnel --helpshows all flags.- Run
supatunnel client server --rate-kbps 50to exercise rate limiting. - Secrets must match on both ends; mismatched secrets fail with decrypt errors.
- The tool prints session lifecycle logs (
OPEN,DATA,ACK,CLOSE).
🏗️ Advanced topics
- Use distinct
SUPATUNNEL_TUNNEL_UUIDvalues for multiple tunnels even within the same room. SUPATUNNEL_ROOMlets you isolate groups of tunnels inside Supabase if needed.- Drop-in AES key rotation: change
SUPATUNNEL_SECRETand coordinate reconnects. - The code keeps unacknowledged packets in memory until they are ACKed; tune
--max-retriesto avoid stuck sessions.
⚠️ 当前不支持
- UDP 流量,目前仅转发 TCP。
- 不提供本地 NAT 穿透或端口映射逻辑;数据必须依赖 Supabase 广播通道完成转发。
- 没有图形化界面,所有操作通过命令行与日志完成。
🧭 Research history
Older prototypes live in the research/ directory (see research/README.md). Production entrypoint is supatunnel in supatunnel/cli.py.
Need more control? Add --rate-kbps per session, or drop into the source for custom broadcast hooks.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file supatunnel-0.1.1.tar.gz.
File metadata
- Download URL: supatunnel-0.1.1.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc41ad03bb9d9022c8ac400d458873beff9601cd7bbebb93598d41b5a56a378c
|
|
| MD5 |
45a0d261d48becb9d0508872900fab82
|
|
| BLAKE2b-256 |
e4371f95677cf52661aa48e671dd7f9c4b1c6c74f3f5c1176797fbd85ea58102
|
File details
Details for the file supatunnel-0.1.1-py3-none-any.whl.
File metadata
- Download URL: supatunnel-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c9b16db728cbd1f5448afd6b9e93589fe3c2c58f0a7f85b1fda3560fcb95288
|
|
| MD5 |
b5039c99f3d3db91d81fc4a86eefabe9
|
|
| BLAKE2b-256 |
03e642175c3c1d3c2e00e961c65f0c5e1e575d9c58a9de7113ef48a2337998a9
|