Python bindings for rathole reverse tunneling proxy
Project description
PyRathole
Python bindings for rathole, a high-performance reverse tunnelling proxy.
🚀 Quick Start
Installation
pip install pyrathole
Basic Usage
import pyrathole
# Start rathole server
pyrathole.start_server("/path/to/server.toml")
# Start rathole client
pyrathole.start_client("/path/to/client.toml")
# Get rathole version
version = pyrathole.version()
print(f"Rathole version: {version}")
Note: This package requires rathole to be installed on your system. Download from rathole releases.
📋 Requirements
- Python 3.8+
- rathole binary installed on your system
- Valid rathole configuration files
🔧 Installing rathole Binary
Before using PyRathole, you need to install the rathole binary on your system:
Option 1: Download Pre-built Binaries (Recommended)
-
Go to rathole releases
-
Download the appropriate binary for your system:
- Linux:
rathole-x86_64-unknown-linux-gnu.tar.gz - macOS:
rathole-x86_64-apple-darwin.tar.gzorrathole-aarch64-apple-darwin.tar.gz - Windows:
rathole-x86_64-pc-windows-gnu.zip
- Linux:
-
Extract and install:
# Linux/macOS tar -xzf rathole-*.tar.gz sudo mv rathole /usr/local/bin/ # Windows # Extract the zip file and add the directory to your PATH
Option 2: Install via Package Manager
macOS (Homebrew)
brew install rathole
Arch Linux
sudo pacman -S rathole
Ubuntu/Debian (via cargo)
cargo install rathole
Option 3: Build from Source
git clone https://github.com/rapiz1/rathole.git
cd rathole
cargo build --release
sudo cp target/release/rathole /usr/local/bin/
Verify Installation
rathole --version
This should output the rathole version number.
⚙️ Configuration
PyRathole uses the same configuration format as native rathole. See the rathole documentation for detailed configuration options.
Example Server Config (server.toml)
[server]
bind_addr = "0.0.0.0:2333"
[server.services.web]
type = "tcp"
bind_addr = "0.0.0.0:8080"
token = "your-secret-token"
Example Client Config (client.toml)
[client]
remote_addr = "your.server.com:2333"
[client.services.web]
type = "tcp"
local_addr = "127.0.0.1:8080"
token = "your-secret-token"
🔧 API Reference
Functions
start_server(config_path: str)- Start rathole server with given config filestart_client(config_path: str)- Start rathole client with given config fileversion() -> str- Get installed rathole version
Error Handling
import pyrathole
try:
pyrathole.start_server("server.toml")
except RuntimeError as e:
print(f"Failed to start server: {e}")
🐛 Troubleshooting
| Error | Cause | Solution |
|---|---|---|
RuntimeError: Failed to start rathole |
rathole not found in PATH | Install rathole binary and ensure it's in your PATH |
RuntimeError: Rathole failed |
Invalid config or network issues | Check configuration file and network connectivity |
RuntimeError: Failed to get version |
rathole not installed | Ensure rathole is properly installed and accessible |
command not found: rathole |
rathole not in PATH | Add rathole to your system PATH or install it properly |
| Permission denied | Insufficient permissions | Use sudo for system-wide installation or install to user directory |
Common Installation Issues
Linux/macOS:
# Check if rathole is installed
which rathole
# If not found, add to PATH
export PATH="/usr/local/bin:$PATH"
Windows:
- Ensure rathole.exe is in a directory that's in your PATH
- Or add the rathole directory to your system PATH environment variable
📚 Documentation
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📄 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
🙏 Acknowledgments
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyrathole-0.1.2.tar.gz.
File metadata
- Download URL: pyrathole-0.1.2.tar.gz
- Upload date:
- Size: 98.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78f8035e81b62bcb200784c96f6e8e8c44ed713e5fd9d4d646e3308b18a606f6
|
|
| MD5 |
a7b795b275d9929ec9a2fa713d0ae411
|
|
| BLAKE2b-256 |
9c509a6a0a08fcf8c30f7c9df39e74caafab6c9324bd3a18b1dffeb1b04a9328
|
File details
Details for the file pyrathole-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pyrathole-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 205.3 kB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0d3fe95d5e0424884a1cf1c47970e7f40b2c1de88727e7c1a1fa4f7352c8042
|
|
| MD5 |
594b906399298f8c5d1b0d450a332771
|
|
| BLAKE2b-256 |
8320ad1918c05d25b5b339593e9e39e660a99925088e60886b7285f2eda6d60a
|