iroh_relay::dns

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

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.

Source

pub fn with_nameserver(nameserver: SocketAddr) -> Self

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

Source

pub fn clear_cache(&self)

Removes all entries from the cache.

Source

pub async fn lookup_txt( &self, host: impl ToString, timeout: Duration, ) -> Result<TxtLookup>

Lookup a TXT record.

Source

pub async fn lookup_ipv4( &self, host: impl ToString, timeout: Duration, ) -> Result<impl Iterator<Item = IpAddr>>

Perform an ipv4 lookup with a timeout.

Source

pub async fn lookup_ipv6( &self, host: impl ToString, timeout: Duration, ) -> Result<impl Iterator<Item = IpAddr>>

Perform an ipv6 lookup with a timeout.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn lookup_node_by_domain_name(&self, name: &str) -> Result<NodeInfo>

Looks up node info by DNS name.

Source

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.

Source

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

Source§

fn clone(&self) -> DnsResolver

Returns a copy 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 From<Resolver<GenericConnector<TokioRuntimeProvider>>> for DnsResolver

Source§

fn from(resolver: TokioResolver) -> Self

Converts to this type from the input type.

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.

§

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

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T