DnsResolver

Struct DnsResolver 

Source
pub struct DnsResolver(/* private fields */);
Available on non-wasm_browser only.
Expand description

The DNS resolver used throughout iroh.

Implementations§

Source§

impl DnsResolver

Source

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.

Source

pub fn with_nameserver(nameserver: SocketAddr) -> Self

Creates a new DNS resolver configured with a single UDP DNS nameserver.

Source

pub fn builder() -> Builder

Creates a builder to construct a DNS resolver with custom options.

Source

pub fn custom(resolver: impl Resolver) -> Self

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.

Source

pub async fn clear_cache(&self)

Removes all entries from the cache.

Source

pub async fn reset(&self)

Recreates the inner resolver.

Source

pub async fn lookup_txt<T: ToString>( &self, host: T, timeout: Duration, ) -> Result<impl Iterator<Item = TxtRecordData>, DnsError>

Looks up a TXT record.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn lookup_endpoint_by_id( &self, endpoint_id: &EndpointId, 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.

Source

pub async fn lookup_endpoint_by_domain_name( &self, name: &str, ) -> Result<EndpointInfo, LookupError>

Looks up endpoint info by DNS name.

Source

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.

Source

pub async fn lookup_endpoint_by_id_staggered( &self, endpoint_id: &EndpointId, 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

Source§

fn clone(&self) -> DnsResolver

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DnsResolver

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DnsResolver

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Resolve for DnsResolver

Source§

fn resolve(&self, name: Name) -> Resolving

Performs DNS resolution on a Name. The return type is a future containing an iterator of SocketAddr. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more