pub fn parse_binding_response(
msg: &[u8],
expected_txid: Option<&[u8; 12]>,
) -> Result<SocketAddr, StunError>Expand description
Parse a STUN Binding success response, returning the reflexive SocketAddr from its
XOR-MAPPED-ADDRESS (preferred) or legacy MAPPED-ADDRESS attribute.
Validates the magic cookie and (when expected_txid is Some) the transaction id, so a stale
or spoofed datagram is rejected. Implements the XOR de-obfuscation of RFC 5389 §15.2.
This is a PURE parser: it does NOT check whether the returned address is a usable
(non-reserved, globally/LAN-dialable) reflexive candidate. A caller wanting a usable
server-reflexive candidate should use query_reflexive_address, which applies the
[is_usable_reflexive_addr] guard on top of parsing.