Skip to main content

ReTunnel - Securely expose local servers to the internet

Project description

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

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

retunnel-2.0.0.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

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

retunnel-2.0.0-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

Details for the file retunnel-2.0.0.tar.gz.

File metadata

  • Download URL: retunnel-2.0.0.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for retunnel-2.0.0.tar.gz
Algorithm Hash digest
SHA256 d844c45e01e2c5166da6d5fea29548fe51e37a14b632b7994e5ef30eecbad9e0
MD5 8d47dfaff3f731af715cb1a44287b12b
BLAKE2b-256 3c076d93b067809a661b86752a508e05e3bd187c008c583404bf75f00488f476

See more details on using hashes here.

File details

Details for the file retunnel-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: retunnel-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 27.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for retunnel-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ca8de05e795cda9ccba1e8d310a3971f77cc3f34fe8f4f5d1f1c0a69a21fbbd
MD5 aa682bb984cff78e2ab8facd020e46b7
BLAKE2b-256 ee5758c4e977fc60b4eadaef46673d6c447dcea4a7de0b074e9dcd755a62bcf6

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