Skip to main content

Module stun

Module stun 

Source
Expand description

STUN client (RFC 5389) on a socket we own, plus NAT classification.

Two servers on different operators are queried so the answers can be compared: the same ip:port from both means a cone NAT and a usable reflexive candidate; the same IP with different ports means the mapping is chosen per destination — symmetric — and the port STUN saw is not the port the pilot would arrive on. Anycast within one provider could hide that, which is why two operators rather than one.

Structs§

NatDiscovery
What STUN could work out about our position behind the NAT.

Enums§

NatType

Constants§

STUN_SERVERS

Functions§

discover
Query every STUN server from sock and classify what we see.
discover_with_timeout
encode_binding_request
Encode a Binding Request with the given 12-byte transaction id.
encode_binding_response
Build a Binding Success Response carrying addr (test helper and useful for a future in-process STUN server).
parse_binding_response
Extract XOR-MAPPED-ADDRESS from a Binding Success Response for txid.