Skip to main content

Tunnel System V4 - Cloudflare Workers based tunnel system

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mp_tunnel-4.0.24.tar.gz (43.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mp_tunnel-4.0.24-py3-none-any.whl (58.1 kB view details)

Uploaded Python 3

File details

Details for the file mp_tunnel-4.0.24.tar.gz.

File metadata

  • Download URL: mp_tunnel-4.0.24.tar.gz
  • Upload date:
  • Size: 43.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for mp_tunnel-4.0.24.tar.gz
Algorithm Hash digest
SHA256 0549097c2dfd3be52d4e453e3054938aa600c36da3a1bfd1538f68b139491255
MD5 7063e18fb8b2628509d55fa993902865
BLAKE2b-256 5decceea8956609c49c429eb389e8e6ea664ef0bd4aa6f91f943a58973b4c95d

See more details on using hashes here.

File details

Details for the file mp_tunnel-4.0.24-py3-none-any.whl.

File metadata

  • Download URL: mp_tunnel-4.0.24-py3-none-any.whl
  • Upload date:
  • Size: 58.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for mp_tunnel-4.0.24-py3-none-any.whl
Algorithm Hash digest
SHA256 033719a1ad92331cada30a80a9f62f56c1dcc46ae68e789cdac5752c1861bf13
MD5 65dcc718e5f40badefe40e224a4e67f7
BLAKE2b-256 53be9aeedf8970e60b87cb7d4f509a06f31b0f151376643b19a33959ae316d17

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page