Skip to main content

Python bindings for rathole reverse tunneling proxy

Project description

PyRathole

PyPI version Python 3.8+ License: Apache-2.0

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)

  1. Go to rathole releases

  2. Download the appropriate binary for your system:

    • Linux: rathole-x86_64-unknown-linux-gnu.tar.gz
    • macOS: rathole-x86_64-apple-darwin.tar.gz or rathole-aarch64-apple-darwin.tar.gz
    • Windows: rathole-x86_64-pc-windows-gnu.zip
  3. 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 file
  • start_client(config_path: str) - Start rathole client with given config file
  • version() -> 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.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

🙏 Acknowledgments

  • rathole - The amazing reverse tunneling proxy
  • PyO3 - Rust-Python bindings
  • maturin - Build tool for Python extensions

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

pyrathole-0.1.2.tar.gz (98.2 MB view details)

Uploaded Source

Built Distribution

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

pyrathole-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl (205.3 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Hashes for pyrathole-0.1.2.tar.gz
Algorithm Hash digest
SHA256 78f8035e81b62bcb200784c96f6e8e8c44ed713e5fd9d4d646e3308b18a606f6
MD5 a7b795b275d9929ec9a2fa713d0ae411
BLAKE2b-256 9c509a6a0a08fcf8c30f7c9df39e74caafab6c9324bd3a18b1dffeb1b04a9328

See more details on using hashes here.

File details

Details for the file pyrathole-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyrathole-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c0d3fe95d5e0424884a1cf1c47970e7f40b2c1de88727e7c1a1fa4f7352c8042
MD5 594b906399298f8c5d1b0d450a332771
BLAKE2b-256 8320ad1918c05d25b5b339593e9e39e660a99925088e60886b7285f2eda6d60a

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