Skip to main content

parse_binding_response

Function parse_binding_response 

Source
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.