Skip to main content

ReTunnel Client

PyPI Version Python Versions License

ReTunnel is a secure tunnel service that allows you to expose local servers to the internet. This is the official Python client library and CLI.

Features

  • 🚀 Easy to use - Single command to expose your local server
  • 🔒 Secure - All connections are encrypted
  • 🌐 HTTP/HTTPS and TCP - Support for web and TCP services
  • 🔑 Automatic registration - No sign-up required for basic usage
  • ⚡ High performance - Built with asyncio for efficiency
  • 🎛️ Professional CLI - Rich terminal interface with Typer

Installation

pip install retunnel

Requires Python 3.9 or higher.

Quick Start

HTTP Tunnel

Expose a local web server on port 8080:

retunnel http 8080

TCP Tunnel

Expose a local TCP service on port 22:

retunnel tcp 22

With Custom Subdomain

Request a specific subdomain (subject to availability):

retunnel http 8080 --subdomain myapp

With Authentication

Protect your tunnel with HTTP Basic Auth:

retunnel http 8080 --auth user:password

Configuration

Server Endpoint

By default, ReTunnel connects to localhost:6400. You can configure this using:

  • Environment variable: RETUNNEL_SERVER_ENDPOINT=your.server.com:port
  • Command-line option: --server your.server.com:port
  • Configuration file: server_addr: your.server.com:port

Save Authentication Token

Save your auth token for persistent access:

retunnel authtoken YOUR_AUTH_TOKEN

Configuration File

Create a retunnel.yml file to define multiple tunnels:

server_addr: ${RETUNNEL_SERVER_ENDPOINT:localhost:6400}
auth_token: ${RETUNNEL_AUTH_TOKEN}
log_level: INFO

tunnels:
  - name: web
    protocol: http
    local_port: 8080
    subdomain: myapp

  - name: api
    protocol: http
    local_port: 3000
    auth: user:pass

  - name: ssh
    protocol: tcp
    local_port: 22

Then start all tunnels:

retunnel start retunnel.yml

Environment Variables

  • RETUNNEL_SERVER_ENDPOINT - Server endpoint (default: localhost:6400)
  • RETUNNEL_AUTH_TOKEN - Authentication token
  • RETUNNEL_LOG_LEVEL - Logging level (DEBUG, INFO, WARNING, ERROR)

Python API

import asyncio
from retunnel import ReTunnelClient, TunnelConfig

async def main():
    # Create client
    client = ReTunnelClient()

    # Connect to server
    await client.connect()

    # Create HTTP tunnel
    config = TunnelConfig(protocol="http", local_port=8080)
    tunnel = await client.request_tunnel(config)

    print(f"Tunnel URL: {tunnel.url}")

    # Keep running
    await asyncio.Event().wait()

asyncio.run(main())

Advanced Usage

Custom Server

Connect to a self-hosted ReTunnel server:

retunnel http 8080 --server your-server.com:8000

Multiple Tunnels

Use the configuration file to manage multiple tunnels simultaneously.

Logging

Set log level for debugging:

retunnel http 8080 --log-level DEBUG

CLI Commands

  • retunnel http PORT - Create HTTP tunnel
  • retunnel tcp PORT - Create TCP tunnel
  • retunnel start CONFIG - Start tunnels from config file
  • retunnel authtoken TOKEN - Save authentication token
  • retunnel config - Manage configuration
  • retunnel version - Show version
  • retunnel credits - Show open source credits

Development

Setup

# Clone repository
git clone https://github.com/retunnel/retunnel-client
cd retunnel-client

# Install with development dependencies
make install-dev

Testing

# Run tests
make test

# Run linting
make lint

# Run type checking
make typecheck

# Format code
make format

Building

make build

License

MIT License - see LICENSE file for details.

Credits

ReTunnel uses these excellent open source libraries:

  • aiohttp - Async HTTP client/server
  • websockets - WebSocket client/server
  • msgpack - Efficient serialization
  • typer - CLI framework
  • rich - Terminal formatting
  • pydantic - Data validation

Support

Metadata

Release files for retunnel 3.3.0

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

Source distribution (sdist)

Source distribution for retunnel 3.3.0
File Size Uploaded
retunnel-3.3.0.tar.gz 68.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for retunnel 3.3.0
File Interpreter ABI Platform
retunnel-3.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 126.2 kB

Release files / retunnel-3.3.0.tar.gz

Download URL retunnel-3.3.0.tar.gz
Size 68.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2c6b2e5a177c49fc038155ca08b7b5847dd481c82bd7855a9d18939f50b24a51
BLAKE2b-256 checksum
How to use checksums
f22d988d32a588209bfb2dbe297a379e17d31004b652005134f263f9212e09e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / retunnel-3.3.0-py3-none-any.whl

Download URL retunnel-3.3.0-py3-none-any.whl
Size 57.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
910973c508cefa8c815d9d424779f22dca2b89a93bbe2aa92a897991a514fd43
BLAKE2b-256 checksum
How to use checksums
43eaac7032d76996ab1e7f3e9ef156f19323ba7769fc9f7edf84d49d251b0223
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release history Release notifications | RSS feed

3.3.2

2 release files

3.3.1

2 release files

This release

3.3.0 This release

2 release files

3.2.4

2 release files

3.2.3

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.5.3

2 release files

2.5.2

2 release files

2.5.1

2 release files

2.1.0

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

0.1.0

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