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() -> DnsResolver
pub fn new() -> DnsResolver
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 with_nameserver(nameserver: SocketAddr) -> DnsResolver
pub fn with_nameserver(nameserver: SocketAddr) -> DnsResolver
Creates a new DNS resolver configured with a single UDP DNS nameserver.
Sourcepub fn custom(resolver: impl Resolver) -> DnsResolver
pub fn custom(resolver: impl Resolver) -> DnsResolver
Creates a new DnsResolver from a struct that implements Resolver.
If you need more customization for DNS resolving than the Builder allows, you can
implement the Resolver trait on a struct and implement DNS resolution
however you see fit.
Sourcepub async fn clear_cache(&self)
pub async fn clear_cache(&self)
Removes all entries from the cache.
Sourcepub async fn lookup_txt<T>(
&self,
host: T,
timeout: Duration,
) -> Result<impl Iterator<Item = TxtRecordData>, DnsError>where
T: ToString,
pub async fn lookup_txt<T>(
&self,
host: T,
timeout: Duration,
) -> Result<impl Iterator<Item = TxtRecordData>, DnsError>where
T: ToString,
Looks up a TXT record.
Sourcepub async fn lookup_ipv4<T>(
&self,
host: T,
timeout: Duration,
) -> Result<impl Iterator<Item = IpAddr> + use<T>, DnsError>where
T: ToString,
pub async fn lookup_ipv4<T>(
&self,
host: T,
timeout: Duration,
) -> Result<impl Iterator<Item = IpAddr> + use<T>, DnsError>where
T: ToString,
Performs an IPv4 lookup with a timeout.
Sourcepub async fn lookup_ipv6<T>(
&self,
host: T,
timeout: Duration,
) -> Result<impl Iterator<Item = IpAddr> + use<T>, DnsError>where
T: ToString,
pub async fn lookup_ipv6<T>(
&self,
host: T,
timeout: Duration,
) -> Result<impl Iterator<Item = IpAddr> + use<T>, DnsError>where
T: ToString,
Performs an IPv6 lookup with a timeout.
Sourcepub async fn lookup_ipv4_ipv6<T>(
&self,
host: T,
timeout: Duration,
) -> Result<impl Iterator<Item = IpAddr> + use<T>, DnsError>where
T: ToString,
pub async fn lookup_ipv4_ipv6<T>(
&self,
host: T,
timeout: Duration,
) -> Result<impl Iterator<Item = IpAddr> + use<T>, DnsError>where
T: ToString,
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_endpoint_by_id(
&self,
endpoint_id: &PublicKey,
origin: &str,
) -> Result<EndpointInfo, LookupError>
pub async fn lookup_endpoint_by_id( &self, endpoint_id: &PublicKey, origin: &str, ) -> Result<EndpointInfo, LookupError>
Looks up endpoint info by EndpointId and origin domain name.
To lookup endpoints that published their endpoint info to the DNS servers run by n0,
pass N0_DNS_ENDPOINT_ORIGIN_PROD as origin.
Sourcepub async fn lookup_endpoint_by_domain_name(
&self,
name: &str,
) -> Result<EndpointInfo, LookupError>
pub async fn lookup_endpoint_by_domain_name( &self, name: &str, ) -> Result<EndpointInfo, LookupError>
Looks up endpoint info by DNS name.
Sourcepub async fn lookup_endpoint_by_domain_name_staggered(
&self,
name: &str,
delays_ms: &[u64],
) -> Result<EndpointInfo, StaggeredError<LookupError>>
pub async fn lookup_endpoint_by_domain_name_staggered( &self, name: &str, delays_ms: &[u64], ) -> Result<EndpointInfo, StaggeredError<LookupError>>
Looks up endpoint 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_endpoint_by_id_staggered(
&self,
endpoint_id: &PublicKey,
origin: &str,
delays_ms: &[u64],
) -> Result<EndpointInfo, StaggeredError<LookupError>>
pub async fn lookup_endpoint_by_id_staggered( &self, endpoint_id: &PublicKey, origin: &str, delays_ms: &[u64], ) -> Result<EndpointInfo, StaggeredError<LookupError>>
Looks up endpoint info by EndpointId 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 moreSource§impl Debug for DnsResolver
impl Debug for DnsResolver
Source§impl Default for DnsResolver
impl Default for DnsResolver
Source§fn default() -> DnsResolver
fn default() -> DnsResolver
Source§impl Resolve for DnsResolver
impl Resolve for DnsResolver
Auto Trait Implementations§
impl Freeze for DnsResolver
impl !RefUnwindSafe for DnsResolver
impl Send for DnsResolver
impl Sync for DnsResolver
impl Unpin for DnsResolver
impl !UnwindSafe for DnsResolver
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more