pub struct SyncResolver { /* private fields */ }Expand description
A simple, synchronous, non-recursive (m)DNS stub resolver.
Implementations§
Source§impl SyncResolver
impl SyncResolver
Sourcepub fn new(sock: SocketAddr) -> Result<Self>
pub fn new(sock: SocketAddr) -> Result<Self>
Creates a new DNS resolver that will contact the given server.
Sourcepub fn new_multicast_v4() -> Result<Self>
pub fn new_multicast_v4() -> Result<Self>
Creates a new mDNS resolver that will use IPv4.
Sourcepub fn new_multicast_v6() -> Result<Self>
pub fn new_multicast_v6() -> Result<Self>
Creates a new mDNS resolver that will use IPv6.
Sourcepub fn add_server(&mut self, server: SocketAddr)
pub fn add_server(&mut self, server: SocketAddr)
Adds another server to be contacted by this resolver.
Calling SyncResolver::resolve or SyncResolver::resolve_domain will send a query to
every server in this list. The first response containing at least one resolved IP address
will be returned.
§Panics
All servers added to the same SyncResolver must match the family of the first server
passed to SyncResolver::new, otherwise this method will panic.
This method will also panic when called on a multicast resolver.
Sourcepub fn set_timeout(&mut self, timeout: Duration) -> Result<()>
pub fn set_timeout(&mut self, timeout: Duration) -> Result<()>
Sets the timeout after which to abort a resolution attempt.
This is the timeout for individual receive operations, not for the whole query. Packets that don’t match the query that was sent will be ignored, but still reset the timeout.
Sourcepub fn resolve(
&mut self,
hostname: &str,
) -> Result<impl Iterator<Item = IpAddr> + '_>
pub fn resolve( &mut self, hostname: &str, ) -> Result<impl Iterator<Item = IpAddr> + '_>
Attempts to resolve hostname using the configured DNS servers.
If the query times out, an error of type io::ErrorKind::WouldBlock or
io::ErrorKind::TimedOut will be returned.
The resolver does not perform recursive resolution (it is a “stub resolver”). It does set
the RD bit in the query, which instructs the server to perform recursion.
Sourcepub fn resolve_domain(
&mut self,
name: &DomainName,
) -> Result<impl Iterator<Item = IpAddr> + '_>
pub fn resolve_domain( &mut self, name: &DomainName, ) -> Result<impl Iterator<Item = IpAddr> + '_>
Attempts to resolve a DomainName using the configured DNS servers.
If the query times out, an error of type io::ErrorKind::WouldBlock or
io::ErrorKind::TimedOut will be returned.
The resolver does not perform recursive resolution (it is a “stub resolver”). It does set
the RD bit in the query, which instructs the server to perform recursion.