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
Create 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 with_nameserver(nameserver: SocketAddr) -> Self
pub fn with_nameserver(nameserver: SocketAddr) -> Self
Create a new DNS resolver configured with a single UDP DNS nameserver.
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Removes all entries from the cache.
Sourcepub async fn lookup_txt(
&self,
host: impl ToString,
timeout: Duration,
) -> Result<TxtLookup>
pub async fn lookup_txt( &self, host: impl ToString, timeout: Duration, ) -> Result<TxtLookup>
Lookup a TXT record.
Sourcepub async fn lookup_ipv4(
&self,
host: impl ToString,
timeout: Duration,
) -> Result<impl Iterator<Item = IpAddr>>
pub async fn lookup_ipv4( &self, host: impl ToString, timeout: Duration, ) -> Result<impl Iterator<Item = IpAddr>>
Perform an ipv4 lookup with a timeout.
Sourcepub async fn lookup_ipv6(
&self,
host: impl ToString,
timeout: Duration,
) -> Result<impl Iterator<Item = IpAddr>>
pub async fn lookup_ipv6( &self, host: impl ToString, timeout: Duration, ) -> Result<impl Iterator<Item = IpAddr>>
Perform an ipv6 lookup with a timeout.
Sourcepub async fn lookup_ipv4_ipv6(
&self,
host: impl ToString,
timeout: Duration,
) -> Result<impl Iterator<Item = IpAddr>>
pub async fn lookup_ipv4_ipv6( &self, host: impl ToString, timeout: Duration, ) -> Result<impl Iterator<Item = IpAddr>>
Resolve 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>
pub async fn resolve_host( &self, url: &Url, prefer_ipv6: bool, timeout: Duration, ) -> Result<IpAddr>
Resolve 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>>
pub async fn lookup_ipv4_staggered( &self, host: impl ToString, timeout: Duration, delays_ms: &[u64], ) -> Result<impl Iterator<Item = IpAddr>>
Perform 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>>
pub async fn lookup_ipv6_staggered( &self, host: impl ToString, timeout: Duration, delays_ms: &[u64], ) -> Result<impl Iterator<Item = IpAddr>>
Perform 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>>
pub async fn lookup_ipv4_ipv6_staggered( &self, host: impl ToString, timeout: Duration, delays_ms: &[u64], ) -> Result<impl Iterator<Item = IpAddr>>
Race 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>
pub async fn lookup_node_by_id( &self, node_id: &NodeId, origin: &str, ) -> Result<NodeInfo>
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>
pub async fn lookup_node_by_domain_name(&self, name: &str) -> Result<NodeInfo>
Looks up node info by DNS name.
Sourcepub async fn lookup_node_by_domain_name_staggered(
&self,
name: &str,
delays_ms: &[u64],
) -> Result<NodeInfo>
pub async fn lookup_node_by_domain_name_staggered( &self, name: &str, delays_ms: &[u64], ) -> Result<NodeInfo>
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>
pub async fn lookup_node_by_id_staggered( &self, node_id: &NodeId, origin: &str, delays_ms: &[u64], ) -> Result<NodeInfo>
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