CHAN.RUN
Restunnel uses a star topology. Each hub sits at the center with exit nodes connecting inbound. Hubs are independent — they don't know about each other.
Server A (Hetzner) Server B (AWS)
┌────────────────────────┐ ┌────────────────────────┐
│ Your Software │ │ Your Crawler │
│ │ │ │ │ │
│ ▼ │ │ ▼ │
│ Restunnel Hub A │ │ Restunnel Hub B │
│ socks5://localhost:1080│ │ socks5://localhost:1080│
└───────┬────────────────┘ └──────────┬─────────────┘
│ │
│ Encrypted tunnels │
│ (exit nodes connect out) │
│ │
┌────┴─────────────────────────────────┴────┐
│ │
▼ ▼
📱 Phone (LTE) 💻 Laptop (Home WiFi)
Connected to: Hub A + Hub B Connected to: Hub AHub — a single binary on your server with three responsibilities:
:9000) — listens for exit node connections via Noise protocol. Silently drops unauthenticated connections. Multiplexes many TCP streams over a single tunnel per node.:1080 SOCKS5, :1081 HTTP CONNECT) — binds to localhost only. Routes requests through connected exit nodes.:8080) — binds to localhost only. Manage nodes and generate QR codes for pairing.Exit nodes — apps on your personal devices. They connect outbound to hubs — they never listen on any port. Zero inbound attack surface.
Your Software Hub Phone (Exit Node)
│ │ │
│ SOCKS5 CONNECT │ │
│ example.com:443 │ │
│─────────────────────►│ │
│ │ CONNECT example.com:443 │
│ │──────────────────────────►│
│ │ │
│ │ │ TCP connect
│ │ │ to example.com
│ │ │
│ │ CONNECT_OK │
│ │◄──────────────────────────│
│ SOCKS5 OK │ │
│◄─────────────────────│ │
│ │ │
│ TLS ClientHello │ DATA │
│─────────────────────►│──────────────────────────►│──► example.com
│ │ │
│ │ DATA │
│◄─────────────────────│◄──────────────────────────│◄── example.com
│ TLS ServerHello │ │The hub and exit node relay encrypted TLS bytes — they never see plaintext. The target website sees the phone's residential IP.
After enrollment, the token is burned. Reconnections authenticate via cryptographic keypair. No passwords, no bearer tokens on the wire.
Restunnel uses the Noise Protocol Framework (Noise_IK with X25519) instead of TLS. The key difference: TLS responds to any client's handshake (fingerprintable), while Noise requires the client to prove identity in the first message. Unauthorized clients get no response — the port appears closed.
Enrollment handshake: Node initiates Noise_IK → sends ENROLL with one-time token → hub validates, stores key, burns token → sends ENROLL_OK.
Reconnection: Node initiates Noise_IK with stored keys → hub checks authorized list → tunnel established (or silent drop if unknown).
After the handshake, the encrypted channel carries binary-framed messages:
┌──────────┬──────────┬───────────┬──────────────┐
│ Type (1B)│ ID (4B) │ Len (4B) │ Payload │
└──────────┴──────────┴───────────┴──────────────┘| Type | Name | Direction | Purpose |
|---|---|---|---|
0x01 | ENROLL | Node → Hub | One-time enrollment |
0x02 | ENROLL_OK | Hub → Node | Enrollment accepted |
0x03/0x04 | PING/PONG | Both | Keepalive (30s interval, 10s timeout) |
0x10 | CONNECT | Hub → Node | Open TCP connection to target |
0x11/0x12 | CONNECT_OK/FAIL | Node → Hub | Connection result |
0x20 | DATA | Both | Raw TCP data for a stream |
0x21 | CLOSE | Both | Close a stream |
0x30 | STATUS | Node → Hub | Periodic status (IP, battery, bandwidth) |
The ID field multiplexes many TCP streams over a single tunnel — one exit node can handle hundreds of concurrent connections.
The security model assumes the hub will be installed and forgotten for months.
Hub is invisible — unauthenticated connections are silently dropped. No error response, no banner. Port scanners see nothing. Even if a vulnerability exists, it's only exploitable by someone with a valid device key.
No open relay — every proxy connection requires an authenticated exit node. No node connected = no traffic flows.
Exit node protection:
Hub protection:
127.0.0.1Authentication:
Noise_IK handshake with X25519 static keys — no bearer tokensKey storage:
| Platform | Storage | Hardware-Backed |
|---|---|---|
| Android | Android Keystore (AES-256-GCM wrapped) | Yes |
| macOS | Keychain | Yes (Apple Silicon / T2) |
| Linux | <data-dir>/node_key.bin (chmod 600) | No |