### Asynchronous STUN Query Source: https://crates.io/crates/stunclient Use this snippet for asynchronous operations to query your external IP address and port using a STUN server with Tokio. Requires `tokio::net::udp::UdpSocket`. ```rust use stunclient::StunClient; use std::net::{SocketAddr,ToSocketAddrs}; let local_addr : SocketAddr = "0.0.0.0:0".parse().unwrap(); let stun_addr = "stun.l.google.com:19302".to_socket_addrs().unwrap().filter(|x|x.is_ipv4()).next().unwrap(); let udp = tokio::net::udp::UdpSocket::bind(&local_addr).unwrap(); let c = StunClient::new(stun_addr); let f = c.query_external_address_async(&udp); let my_external_addr = f.await.unwrap(); ``` -------------------------------- ### Synchronous STUN Query Source: https://crates.io/crates/stunclient Use this snippet for synchronous operations to query your external IP address and port using a STUN server. Requires `std::net::UdpSocket`. ```rust use std::net::UdpSocket; use stunclient::StunClient; use std::net::{SocketAddr,ToSocketAddrs}; let local_addr : SocketAddr = "0.0.0.0:0".parse().unwrap(); let stun_addr = "stun.l.google.com:19302".to_socket_addrs().unwrap().filter(|x|x.is_ipv4()).next().unwrap(); let udp = UdpSocket::bind(local_addr).unwrap(); let c = StunClient::new(stun_addr); let my_external_addr = c.query_external_address(&udp).unwrap(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.