# RPort - WebRTC-based remote port forwarding tool written in Rust
RPort is a modern, WebRTC-based remote port forwarding tool written in Rust. It enables secure peer-to-peer connections for port forwarding, remote access, and network tunneling without requiring complex NAT traversal configurations.
It is built on top of [rustrtc](https://github.com/restsend/rustrtc), a pure Rust WebRTC implementation.
## Features
- π **WebRTC-based P2P connections** - Direct peer-to-peer tunneling
- π **Secure tunneling** - End-to-end encrypted connections
- π **Configuration file support** - TOML-based configuration with CLI override
- π **IPv6 filtering** - Automatic IPv6 candidate filtering for better compatibility
- π§ **Multiple operation modes** - Agent, client, and proxy modes
- π **Background daemon support** - Run as a system daemon with custom log files
- π **Structured logging** - Comprehensive logging with tracing support
- β‘ **High performance** - Built with Tokio async runtime
- π **Built-in TURN server** - No need for third-party TURN servers
## Architecture
```
βββββββββββββββ WebRTC P2P βββββββββββββββ
β Client βββββββββββββββββββΊβ Agent β
β β β β
β rport -p β β rport -t β
β 8080:22 β β 22 --id β
βββββββββββββββ βββββββββββββββ
β β
β β
βΌ βΌ
βββββββββββββββ βββββββββββββββ
βLocal Serviceβ βRemote Serverβ
β :8080 β β :22 (SSH) β
βββββββββββββββ βββββββββββββββ
```
## Quick Start
### 1. Install
```bash
cargo install rport rport-server
```
### 2. Run Server (Coordinator)
```bash
rport-server --addr 0.0.0.0:3000
```
### 3. Run Agent (Remote machine)
```bash
# Forward remote port 22 to the server with ID "my-server"
rport --target 22 --id my-server --token secret-token --server http://your-server:3000
```
### 4. Connect Client (Local machine)
```bash
# Map local port 8080 to remote "my-server"
rport --port 8080 --id my-server --token secret-token --server http://your-server:3000
# Now you can SSH through the tunnel
ssh user@localhost -p 8080
```
## SSH Integration
Easily connect without direct port mapping using `ProxyCommand`:
```bash
# Direct command
ssh -o ProxyCommand='rport --id my-server --token secret-token --server http://your-server:3000' user@localhost
# via ~/.ssh/config
Host my-remote
ProxyCommand rport --id my-server --token secret-token --server http://your-server:3000
User ubuntu
```
## Configuration
RPort loads configuration from `~/.rport.toml`:
```toml
token = "secret-token"
server = "http://your-server:3000"
# Optional: Add ICE servers
[[ice_servers]]
urls = ["stun:stun.l.google.com:19302"]
```
## Advanced Usage
- **Daemon Mode**: Append `--daemon --log-file rport.log` to the command.
- **Troubleshooting**: Use `RUST_LOG=rport=debug` for verbose logs.
- **NAT**: Built-in TURN server handles most NAT scenarios automatically.
## Security Considerations
- Use strong tokens and restrict configuration file permissions (`chmod 600`).
- Agent listing functionality is disabled to prevent information disclosure.
## Build on linux
```bash
cargo build -r --target x86_64-unknown-linux-musl -p rport
cargo build -r --target x86_64-pc-windows-gnu -p rport
cargo build -r --target aarch64-apple-darwin -p rport
```