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.
- π 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
pip install retunnel
Requires Python 3.9 or higher.
Expose a local web server on port 8080:
retunnel http 8080
Expose a local TCP service on port 22:
retunnel tcp 22
Request a specific subdomain (subject to availability):
retunnel http 8080 --subdomain myapp
Protect your tunnel with HTTP Basic Auth:
retunnel http 8080 --auth user:password
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 your auth token for persistent access:
retunnel authtoken YOUR_AUTH_TOKEN
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
RETUNNEL_SERVER_ENDPOINT
- Server endpoint (default:localhost:6400
)RETUNNEL_AUTH_TOKEN
- Authentication tokenRETUNNEL_LOG_LEVEL
- Logging level (DEBUG, INFO, WARNING, ERROR)
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())
Connect to a self-hosted ReTunnel server:
retunnel http 8080 --server your-server.com:8000
Use the configuration file to manage multiple tunnels simultaneously.
Set log level for debugging:
retunnel http 8080 --log-level DEBUG
retunnel http PORT
- Create HTTP tunnelretunnel tcp PORT
- Create TCP tunnelretunnel start CONFIG
- Start tunnels from config fileretunnel authtoken TOKEN
- Save authentication tokenretunnel config
- Manage configurationretunnel version
- Show versionretunnel credits
- Show open source credits
# Clone repository
git clone https://github.com/retunnel/retunnel-client
cd retunnel-client
# Install with development dependencies
make install-dev
# Run tests
make test
# Run linting
make lint
# Run type checking
make typecheck
# Format code
make format
make build
MIT License - see LICENSE file for details.
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
- Documentation: https://docs.retunnel.com
- Issues: https://github.com/retunnel/retunnel-client/issues
- Email: support@retunnel.com