pub struct StunClient {
pub timeout: Duration,
pub retry_interval: Duration,
pub stun_server: SocketAddr,
pub software: Option<&'static str>,
}
Expand description
Options for querying STUN server
Fields§
§timeout: Duration
“End-to-end” timeout for the operation.
retry_interval: Duration
How often to repeat STUN binding requests
stun_server: SocketAddr
Address of the STUN server
software: Option<&'static str>
SOFTWARE
attribute value in binding request
Implementations§
Source§impl StunClient
impl StunClient
Sourcepub fn new(stun_server: SocketAddr) -> Self
pub fn new(stun_server: SocketAddr) -> Self
A constructor with default parameters
Sourcepub fn with_google_stun_server() -> Self
pub fn with_google_stun_server() -> Self
Use hard coded STUN server stun.l.google.com:19302
.
Not for production use, for tests, prototypes and demos. May block the thread. May panic in case of address resolution problems.
Sourcepub fn set_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn set_timeout(&mut self, timeout: Duration) -> &mut Self
Set timeout
field, builder pattern.
Sourcepub fn set_retry_interval(&mut self, retry_interval: Duration) -> &mut Self
pub fn set_retry_interval(&mut self, retry_interval: Duration) -> &mut Self
Set retry_interval
field, builder pattern.
Sourcepub fn set_software(&mut self, software: Option<&'static str>) -> &mut Self
pub fn set_software(&mut self, software: Option<&'static str>) -> &mut Self
Set software
field, builder pattern.
Source§impl StunClient
impl StunClient
Sourcepub fn query_external_address(
&self,
udp: &UdpSocket,
) -> Result<SocketAddr, Error>
pub fn query_external_address( &self, udp: &UdpSocket, ) -> Result<SocketAddr, Error>
Get external (server-reflexive transport address) IP address and port of specified UDP socket
Sourcepub async fn query_external_address_async(
self,
udp: &UdpSocket,
) -> Result<SocketAddr, Error>
pub async fn query_external_address_async( self, udp: &UdpSocket, ) -> Result<SocketAddr, Error>
async version of query_external_address
.
Requires async
crate feature to be enabled (it is by default)
Auto Trait Implementations§
impl Freeze for StunClient
impl RefUnwindSafe for StunClient
impl Send for StunClient
impl Sync for StunClient
impl Unpin for StunClient
impl UnwindSafe for StunClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more