finds.dev

pion/stun

A Go implementation of STUN

View on GitHubHomepage ↗

★ 862GoMITupdated Oct 2026

// the take

A low-level, dependency-free Go implementation of STUN (RFC 5389) plus several related RFCs, used internally by pion/webrtc. It's for people who need to build or debug NAT traversal tooling directly on top of the protocol, not for someone wanting a drop-in NAT-punching library.

The zero-allocation claim isn't just marketing — the benchmark table in the README shows 0 B/op across nearly every hot-path operation (message encode/decode, attribute add/get, fingerprint, XOR). It covers more than bare STUN: RFC 5769 test vectors, RFC 6062 TURN-over-TCP extensions, and RFC 5780 NAT behavior discovery with a working `cmd/stun-nat-behaviour` tool you can actually run. Testing goes past unit tests into e2e runs against a real coturn server and fuzz corpora for message parsing, which is more protocol-correctness rigor than most small Go networking libs bother with.

Documentation is thin — one binding-request example in the README and then you're on your own with godoc and the test files to learn client lifecycle, retransmission tuning (`WithRTO`), or how retries actually behave under packet loss. The README still says Go 1.12 is what's tested in CI, which for a repo pushed in October 2026 is either badly stale documentation or a sign the CI matrix description hasn't kept up with the real toolchain. ALTERNATE-SERVER support (RFC 5389 §11) is still just a planned item against an old open issue, so if a STUN server redirects you, this library won't follow it. It's also a toolkit, not a solution: constructing and sending messages is manual attribute composition, so in practice almost everyone pulls this in transitively via pion/ice or pion/webrtc rather than using it standalone.

We read the README, the directory tree and a key source file in October 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
862
Forks
121
Language
Go
License
MIT
Last commit
20 Oct 2026

// nearby

If stun isn't quite it.

All repos →