How it connects, and home servers

Back to the README. New to this? Chapter 2, Connect your phone walks through it in a few minutes.

Browser (client) ── WebRTC data channel, direct, end-to-end encrypted ──► Your VPS app.termenbox.dev one UDP port termenbox-server + tmux │ │ └── GitHub login ── signed directory (address + key, never traffic) ◄──────┘

A server is one identity (its key and certificate fingerprint) that a client reaches over several candidate paths and races: your LAN address, a public IPv4 or IPv6 address, an overlay address (Tailscale, WireGuard) and, later, a tunnel. The server signs the list and sends it to each client after login; the app tries the paths, keeps the first that connects, shows which one it is using (Direct, LAN, Tunnel) and, after a Wi-Fi to cellular change or a missed heartbeat, races again and re-attaches by itself. When nothing connects it lists every path it tried, why each failed and one fix.

At start the server checks where it sits and prints a short block: whether it has a public address, IPv6 or an overlay, whether the router's WAN address is private or shared (carrier-grade NAT, where no port forward can help), and whether the router opened the UDP port for it by PCP, NAT-PMP or UPnP (renewed every half lease, removed on exit). It says mapped, not verified from outside: nothing outside confirms the port is reachable, so a router that accepted the mapping can still sit behind a firewall you do not control.

The installer prints the same pairing block on every run, so a server on your own network is added by scanning it. To use a server on its own network, with no directory or internet:

TERMENBOX_LAN_ONLY=1 termenbox-server # no directory announcements, no public-IP lookup, no router mapping termenbox-server --print-pairing # a link and a QR code for your phone

Open the link or scan the code on a phone on the same network. The app checks the signature, shows the server's name and fingerprint, and connects only when you confirm; compare the fingerprint with the one on the server. An unclaimed server's link also claims it. The link carries the signed list in its fragment, which no host sees. LAN and overlay addresses never go to the public directory. A server behind carrier-grade NAT with no relay can only be reached from its own network or over an overlay: the app says so when it fails.

Tunnels: reaching a server from anywhere

A tunnel is a property of its server, in your own Cloudflare account. Each server has at most one, and the app never guesses which server you mean.

The assisted way

A server behind a router you cannot change, or inside WSL2's own NAT, cannot take an inbound UDP connection. Termenbox can still connect an assisted way, through a free Cloudflare account that you own. Nothing runs on the project's account, and nothing is shared with it.

On the server, once:

termenbox-server --setup-cloudflare # reads a Cloudflare API token from stdin, uses it once, never stores it

The token needs Workers Scripts: Edit, Account Settings: Read and Cloudflare Calls (create it at dash.cloudflare.com, My Profile, API Tokens). The command deploys a small signaling Worker (termenbox-relay-<hash>) and a TURN key in your account, keeps only the TURN key's id and its credential-minting token in relay.json (mode 0600, next to the server's other state), and prints the Worker's address, the free allowance and the cap.

Not a LAN-only server: with TERMENBOX_LAN_ONLY the server never contacts STUN or the Worker. On WSL2 you can instead set networkingMode=mirrored (the installer prints the steps); --setup-cloudflare is the alternative when you cannot or would rather not.

Servers inside a virtual machine

A server inside a NAT'd VM (WSL2 in its default NAT mode, VirtualBox NAT, Docker Desktop) advertises an address that only the VM can use, so other devices on your network cannot reach it. On WSL2 set networkingMode=mirrored in %UserProfile%\.wslconfig, run wsl --shutdown in PowerShell, and allow the UDP port through Windows Firewall; the installer prints these steps when it sees WSL. Otherwise bridge the VM, forward the port, or use an overlay such as Tailscale.

View as Markdown Report a problem Documentation for version 0.2.2