pub struct DnsResolver(/* private fields */);wasm_browser only.Expand description
The DNS resolver used throughout iroh.
Implementations§
Source§impl DnsResolver
impl DnsResolver
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new DNS resolver with sensible cross-platform defaults.
We first try to read the system’s resolver from /etc/resolv.conf.
This does not work at least on some Androids, therefore we fallback
to the default ResolverConfig which uses eg. to google’s 8.8.8.8 or 8.8.4.4.
Sourcepub fn custom(resolver: impl Resolver) -> Self
pub fn custom(resolver: impl Resolver) -> Self
Creates a new DnsResolver from a struct that implements Resolver.
Resolver is implemented for [hickory_resolver::TokioResolver], so you can construct
a [TokioResolver] and pass that to this function.
To use a different DNS resolver, you need to implement Resolver for your custom resolver
and then pass to this function.
Sourcepub fn with_nameserver(nameserver: SocketAddr) -> Self
pub fn with_nameserver(nameserver: SocketAddr) -> Self
Creates a new DNS resolver configured with a single UDP DNS nameserver.
Sourcepub async fn clear_cache(&self)
pub async fn clear_cache(&self)
Removes all entries from the cache.
Sourcepub async fn lookup_txt<T: ToString>(
&self,
host: T,
timeout: Duration,
) -> Result<impl Iterator<Item = TxtRecordData>, DnsError>
pub async fn lookup_txt<T: ToString>( &self, host: T, timeout: Duration, ) -> Result<impl Iterator<Item = TxtRecordData>, DnsError>
Looks up a TXT record.
Sourcepub async fn lookup_ipv4<T: ToString>(
&self,
host: T,
timeout: Duration,
) -> Result<impl Iterator<Item = IpAddr> + use<T>, DnsError>
pub async fn lookup_ipv4<T: ToString>( &self, host: T, timeout: Duration, ) -> Result<impl Iterator<Item = IpAddr> + use<T>, DnsError>
Performs an IPv4 lookup with a timeout.
Sourcepub async fn lookup_ipv6<T: ToString>(
&self,
host: T,
timeout: Duration,
) -> Result<impl Iterator<Item = IpAddr> + use<T>, DnsError>
pub async fn lookup_ipv6<T: ToString>( &self, host: T, timeout: Duration, ) -> Result<impl Iterator<Item = IpAddr> + use<T>, DnsError>
Performs an IPv6 lookup with a timeout.
Sourcepub async fn lookup_ipv4_ipv6<T: ToString>(
&self,
host: T,
timeout: Duration,
) -> Result<impl Iterator<Item = IpAddr> + use<T>, DnsError>
pub async fn lookup_ipv4_ipv6<T: ToString>( &self, host: T, timeout: Duration, ) -> Result<impl Iterator<Item = IpAddr> + use<T>, DnsError>
Resolves IPv4 and IPv6 in parallel with a timeout.
LookupIpStrategy::Ipv4AndIpv6 will wait for ipv6 resolution timeout, even if it is
not usable on the stack, so we manually query both lookups concurrently and time them out
individually.
Sourcepub async fn resolve_host(
&self,
url: &Url,
prefer_ipv6: bool,
timeout: Duration,
) -> Result<IpAddr, DnsError>
pub async fn resolve_host( &self, url: &Url, prefer_ipv6: bool, timeout: Duration, ) -> Result<IpAddr, DnsError>
Resolves a hostname from a URL to an IP address.
Sourcepub async fn lookup_ipv4_staggered(
&self,
host: impl ToString,
timeout: Duration,
delays_ms: &[u64],
) -> Result<impl Iterator<Item = IpAddr>, StaggeredError<DnsError>>
pub async fn lookup_ipv4_staggered( &self, host: impl ToString, timeout: Duration, delays_ms: &[u64], ) -> Result<impl Iterator<Item = IpAddr>, StaggeredError<DnsError>>
Performs an IPv4 lookup with a timeout in a staggered fashion.
From the moment this function is called, each lookup is scheduled after the delays in
delays_ms with the first call being done immediately. [200ms, 300ms] results in calls
at T+0ms, T+200ms and T+300ms. The timeout is applied to each call individually. The
result of the first successful call is returned, or a summary of all errors otherwise.
Sourcepub async fn lookup_ipv6_staggered(
&self,
host: impl ToString,
timeout: Duration,
delays_ms: &[u64],
) -> Result<impl Iterator<Item = IpAddr>, StaggeredError<DnsError>>
pub async fn lookup_ipv6_staggered( &self, host: impl ToString, timeout: Duration, delays_ms: &[u64], ) -> Result<impl Iterator<Item = IpAddr>, StaggeredError<DnsError>>
Performs an IPv6 lookup with a timeout in a staggered fashion.
From the moment this function is called, each lookup is scheduled after the delays in
delays_ms with the first call being done immediately. [200ms, 300ms] results in calls
at T+0ms, T+200ms and T+300ms. The timeout is applied to each call individually. The
result of the first successful call is returned, or a summary of all errors otherwise.
Sourcepub async fn lookup_ipv4_ipv6_staggered(
&self,
host: impl ToString,
timeout: Duration,
delays_ms: &[u64],
) -> Result<impl Iterator<Item = IpAddr>, StaggeredError<DnsError>>
pub async fn lookup_ipv4_ipv6_staggered( &self, host: impl ToString, timeout: Duration, delays_ms: &[u64], ) -> Result<impl Iterator<Item = IpAddr>, StaggeredError<DnsError>>
Races an IPv4 and IPv6 lookup with a timeout in a staggered fashion.
From the moment this function is called, each lookup is scheduled after the delays in
delays_ms with the first call being done immediately. [200ms, 300ms] results in calls
at T+0ms, T+200ms and T+300ms. The timeout is applied as stated in
Self::lookup_ipv4_ipv6. The result of the first successful call is returned, or a
summary of all errors otherwise.
Sourcepub async fn lookup_node_by_id(
&self,
node_id: &NodeId,
origin: &str,
) -> Result<NodeInfo, LookupError>
pub async fn lookup_node_by_id( &self, node_id: &NodeId, origin: &str, ) -> Result<NodeInfo, LookupError>
Looks up node info by NodeId and origin domain name.
To lookup nodes that published their node info to the DNS servers run by n0,
pass N0_DNS_NODE_ORIGIN_PROD as origin.
Sourcepub async fn lookup_node_by_domain_name(
&self,
name: &str,
) -> Result<NodeInfo, LookupError>
pub async fn lookup_node_by_domain_name( &self, name: &str, ) -> Result<NodeInfo, LookupError>
Looks up node info by DNS name.
Sourcepub async fn lookup_node_by_domain_name_staggered(
&self,
name: &str,
delays_ms: &[u64],
) -> Result<NodeInfo, StaggeredError<LookupError>>
pub async fn lookup_node_by_domain_name_staggered( &self, name: &str, delays_ms: &[u64], ) -> Result<NodeInfo, StaggeredError<LookupError>>
Looks up node info by DNS name in a staggered fashion.
From the moment this function is called, each lookup is scheduled after the delays in
delays_ms with the first call being done immediately. [200ms, 300ms] results in calls
at T+0ms, T+200ms and T+300ms. The result of the first successful call is returned, or a
summary of all errors otherwise.
Sourcepub async fn lookup_node_by_id_staggered(
&self,
node_id: &NodeId,
origin: &str,
delays_ms: &[u64],
) -> Result<NodeInfo, StaggeredError<LookupError>>
pub async fn lookup_node_by_id_staggered( &self, node_id: &NodeId, origin: &str, delays_ms: &[u64], ) -> Result<NodeInfo, StaggeredError<LookupError>>
Looks up node info by NodeId and origin domain name.
From the moment this function is called, each lookup is scheduled after the delays in
delays_ms with the first call being done immediately. [200ms, 300ms] results in calls
at T+0ms, T+200ms and T+300ms. The result of the first successful call is returned, or a
summary of all errors otherwise.
Trait Implementations§
Source§impl Clone for DnsResolver
impl Clone for DnsResolver
Source§fn clone(&self) -> DnsResolver
fn clone(&self) -> DnsResolver
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more