Skip to main content

Tunnel V4

A modern tunnel system built on Cloudflare Workers and Durable Objects.

Features

  • 🚀 Remote Terminal - SSH-like terminal access to your servers
  • 📡 SOCKS5 Proxy - Secure proxy through your nodes
  • ⚡ Command Execution - Run commands remotely
  • 🔒 Secure - End-to-end encrypted connections
  • 🌍 Global - Powered by Cloudflare's edge network

Installation

pip install mp-tunnel

Quick Start

Start Agent on Your Server

# Basic usage
tunnel agent --id my-server @all

# With custom tags
tunnel agent --id my-server --tags env=prod,region=us @all

# Specific services only
tunnel agent --id my-server @term @socks5

Use CLI to Connect

# List nodes
tunnel list

# Remote terminal
tunnel term --node my-server

# Execute command
tunnel exec --node my-server "uptime"

# SOCKS5 proxy
tunnel socks5 --node my-server --port 1080

Configuration

Environment Variables

  • TUNNEL_WORKER_URL - Override default Worker URL
  • TUNNEL_ENV - Environment (dev/prod)
  • TUNNEL_DEBUG - Enable debug logging

Custom Worker URL

export TUNNEL_WORKER_URL="wss://your-worker.workers.dev"
tunnel agent --id my-server @all

Services

Built-in Services

  • @all - All services (exec, term, socks5)
  • @exec - Remote command execution
  • @term - Remote terminal
  • @socks5 - SOCKS5 proxy

Port Forwarding

# Forward local HTTP service
tunnel agent --id my-server myapi:8080:http

# Forward local TCP service  
tunnel agent --id my-server mysql:3306:tcp

HTTP Forward (支持 HTTP 和 WebSocket)

HTTP forward 类型统一支持 HTTP 请求和 WebSocket 升级:

# 启动 Agent,转发本地 HTTP/WebSocket 服务
tunnel agent --id my-server myservice:8080:http

访问方式:

  • 子域名模式: https://myservice-tun.your-domain.com/path
  • 路径模式: https://your-domain.com/http/myservice/path

本地地址自动替换:

对于返回本地地址的服务(如 Chrome DevTools Protocol),Agent 会自动将 JSON 响应中的 127.0.0.1:port 替换为占位符,Worker 再替换为公网域名。

示例 - 连接远程 CDP 浏览器:

from playwright.sync_api import sync_playwright

# 启动 Agent: tunnel agent --id browser orbita:9222:http

with sync_playwright() as p:
    # 使用 https:// (Playwright 会自动获取 /json/version)
    browser = p.chromium.connect_over_cdp("https://orbita-tun.your-domain.com")
    page = browser.new_page()
    page.goto("https://example.com")
    browser.close()

Development

# Clone repository
git clone https://github.com/yourusername/tunnel-v4.git
cd tunnel-v4

# Install in development mode
export TUNNEL_DEV=1
pip install -e .

# Run agent (development uses tunnel4 command)
tunnel4 agent --id test @all

License

MIT License

Links

Metadata

Release files for mp-tunnel 4.0.30

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mp-tunnel 4.0.30
File Size Uploaded
mp_tunnel-4.0.30.tar.gz 45.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mp-tunnel 4.0.30
File Interpreter ABI Platform
mp_tunnel-4.0.30-py3-none-any.whl Python 3 none any Details

Total release size: 105.6 kB

Release files / mp_tunnel-4.0.30.tar.gz

Download URL mp_tunnel-4.0.30.tar.gz
Size 45.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bb59a8d0a5f2fcd252dad3f93c268be898c73c1f20fb876e87fb7692b840482c
BLAKE2b-256 checksum
How to use checksums
521182c095b3d910a91748a6c8383a8c6775ab9720502d1bc59f97906b2f52e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / mp_tunnel-4.0.30-py3-none-any.whl

Download URL mp_tunnel-4.0.30-py3-none-any.whl
Size 59.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46eaa15f8a142972a6d4849b9382b4372813c3322bb3cf872cea92c4b9b4b090
BLAKE2b-256 checksum
How to use checksums
fab592aea7860603f81b4fa8c95d81d2cb0b29ced0a02e362b19dd8ccfa51e77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

4.0.30 This release

2 release files

4.0.19

2 release files

4.0.17

2 release files

4.0.16

2 release files

4.0.15

2 release files

4.0.14

2 release files

4.0.13

2 release files

4.0.12

2 release files

4.0.11

2 release files

4.0.10

2 release files

4.0.9

2 release files

4.0.8

2 release files

4.0.7

2 release files

4.0.6

2 release files

4.0.5

1 release file

4.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page