Fork me on GitHub
Digital Commons

go-turn

STUN and TURN for WebRTC peers that cannot reach each other directly โ€” a symmetric NAT, a full-tunnel VPN, a network that only lets HTTPS out โ€” as one daemon, turnd, on one host.

STUN Binding ยท RFC 8489TURN ยท RFC 8656UDP, TCP or TLS on 443credentials behind an OpenID Connect logingRPC rendezvous over WebSocketPROXY protocol v2fuzzed decoders
zsh
$ go install github.com/go-turn/turn/cmd/turnd@latest
$ go install github.com/go-turn/turn/cmd/turnprobe@latest
$ turnprobe --server 'turns:turn.example.org:443?transport=tcp' ...
PASS turns:turn.example.org:443?transport=tcp relay-a=... relay-b=...
One organisation, 1 repository of code

Two WebRTC peers sometimes cannot open a connection to one another, and something on the public Internet has to carry the traffic. turnd is that something: it answers STUN, relays TURN, mints short-lived credentials only after an OpenID Connect login through go-authn, and runs a rendezvous, so a host opens a room, shares one link, and the guest's answer comes back on its own.

It is the relay the go-tex playground uses for live collaboration over go-crdt/collab.

Repositories

turn cli

turnd, turnprobe, stun, server, creds, session, rendezvous

github.com/pion/turn/v4 allocates, permits, binds a channel and round-trips data through the server over UDP and TCP

STUN and TURN in pure Go for WebRTC peers that cannot reach each other directly. One daemon, turnd, serves STUN Binding (RFC 8489), a TURN relay (RFC 8656) over UDP, TCP or TLS on 443, short-lived credentials minted only after an OpenID Connect login, and a rendezvous: a room a host opens and shares as one link, over gRPC carried on a WebSocket. The relay never reaches loopback, private or link-local addresses by default, and every secret is a file, never a flag value or an environment variable. turnprobe proves a deployed relay end to end.

CI

A leaked room link lets a stranger knock, not enter

A guest who joins a room is pending: it can only receive. It cannot send, cannot get credentials, and counts against a separate pending cap and a pending TTL. The host sees the knock and decides; only an admitted guest produces a join and is charged to the host's room. The relay itself refuses to carry traffic to loopback, private, link-local or its own addresses, except between two clients' relayed ports, so the host's SSH, HTTPS and TURN listeners stay unreachable through it.