package stun
import "tailscale.com/net/stun"
Package STUN generates STUN request packets and parses response packets.
Index ¶
- Variables
- func Is(b []byte) bool
- func Request(tID TxID) []byte
- func Response(txID TxID, addrPort netip.AddrPort) []byte
- type TxID
Examples ¶
Variables ¶
var ( ErrNotSTUN = errors.New("response is not a STUN packet") ErrNotSuccessResponse = errors.New("STUN packet is not a response") ErrMalformedAttrs = errors.New("STUN response has malformed attributes") ErrNotBindingRequest = errors.New("STUN request not a binding request") ErrWrongSoftware = errors.New("STUN request came from non-Tailscale software") ErrNoFingerprint = errors.New("STUN request didn't end in fingerprint") ErrWrongFingerprint = errors.New("STUN request had bogus fingerprint") )
Functions ¶
func Is ¶
Is reports whether b is a STUN message.
func Request ¶
Request generates a binding request STUN packet. The transaction ID, tID, should be a random sequence of bytes.
func Response ¶
Response generates a binding response.
Types ¶
type TxID ¶
type TxID [12]byte
TxID is a transaction ID.
func NewTxID ¶
func NewTxID() TxID
NewTxID returns a new random TxID.
func ParseBindingRequest ¶
ParseBindingRequest parses a STUN binding request.
It returns an error unless it advertises that it came from Tailscale.
func ParseResponse ¶
ParseResponse parses a successful binding response STUN packet. The IP address is extracted from the XOR-MAPPED-ADDRESS attribute.
Source Files ¶
stun.go
Directories ¶
Path | Synopsis |
---|---|
net/stun/stuntest | Package stuntest provides a STUN test server. |
- Version
- v1.84.1 (latest)
- Published
- May 29, 2025
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 9 hours ago –
Tools for package owners.