pub struct Builder { /* private fields */ }wasm_browser only.Expand description
Builder for DnsResolver.
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn with_system_defaults(self) -> Builder
pub fn with_system_defaults(self) -> Builder
Reads the host system’s DNS configuration when the resolver builds.
+Implementations§
Source§impl Builder
impl Builder
Sourcepub fn with_system_defaults(self) -> Builder
pub fn with_system_defaults(self) -> Builder
Reads the host system’s DNS configuration when the resolver builds.
On Linux, macOS, and Windows this picks up the operating
system’s nameserver list. On Android the system reader is
opt-in: by default the builder uses a built-in public DNS
@@ -7,19 +7,17 @@ fallback, and callers that need the device’s per-network DNS
supply the necessary JNI handles up front by calling
install_android_jni_context (exported at the crate root,
Android only).
The same public fallback (Cloudflare and Google over UDP and
-TCP, plus DNS-over-HTTPS when the tls-ring or
-tls-aws-lc-rs feature is enabled) is used on any platform
-where the system reader returns nothing.
Sourcepub fn with_nameserver(self, addr: SocketAddr, protocol: DnsProtocol) -> Builder
pub fn with_nameserver(self, addr: SocketAddr, protocol: DnsProtocol) -> Builder
Adds a single nameserver.
-Sourcepub fn with_nameservers(
+
The same public fallback (Google over UDP and TCP) is used on
+any platform where the system reader returns nothing.
+
pub fn with_nameservers( +
The same public fallback (Google over UDP and TCP) is used on +any platform where the system reader returns nothing.
+Sourcepub fn with_nameserver(self, addr: SocketAddr, protocol: DnsProtocol) -> Builder
pub fn with_nameserver(self, addr: SocketAddr, protocol: DnsProtocol) -> Builder
Adds a single nameserver.
+Sourcepub fn with_nameservers(
self,
nameservers: impl IntoIterator<Item = (SocketAddr, DnsProtocol)>,
) -> Builder
pub fn with_nameservers( self, nameservers: impl IntoIterator<Item = (SocketAddr, DnsProtocol)>, ) -> Builder
Adds a list of nameservers.
-Sourcepub fn tls_client_config(self, client_config: ClientConfig) -> Builder
pub fn tls_client_config(self, client_config: ClientConfig) -> Builder
Sets a custom TLS verification config.
+Sourcepub fn tls_client_config(self, client_config: ClientConfig) -> Builder
pub fn tls_client_config(self, client_config: ClientConfig) -> Builder
Sets a custom TLS verification config.
This is only used with DNS-over-TLS and DNS-over-HTTPS, and requires enabling either the ring or aws-lc-rs feature.
-Sourcepub fn build(self) -> DnsResolver
pub fn build(self) -> DnsResolver
Builds the DNS resolver.
+Sourcepub fn build(self) -> DnsResolver
pub fn build(self) -> DnsResolver
Builds the DNS resolver.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl !RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl !UnwindSafe for Builder
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
diff --git a/pr/4199/docs/iroh/dns/struct.DnsResolver.html b/pr/4199/docs/iroh/dns/struct.DnsResolver.html
index 25ffda972c..37342324cd 100644
--- a/pr/4199/docs/iroh/dns/struct.DnsResolver.html
+++ b/pr/4199/docs/iroh/dns/struct.DnsResolver.html
@@ -1,47 +1,46 @@
-DnsResolver in iroh::dns - Rust DnsResolver
pub struct DnsResolver { /* private fields */ }
Available on non-wasm_browser only.Expand description
The DNS resolver used throughout iroh.
+DnsResolver in iroh::dns - Rust DnsResolver
pub struct DnsResolver { /* private fields */ }
Available on non-wasm_browser only.Expand description
The DNS resolver used throughout iroh.
By default, we use a built-in resolver that reads the system’s DNS configuration.
The nameservers can be customized by constructing the resolver with Self::builder.
Alternatively, you can create a fully custom DNS resolver by implementing the Resolver
trait and creating the resolver with Self::custom.
-Implementations§
Source§impl DnsResolver
Sourcepub fn new() -> DnsResolver
Creates a new resolver with sensible cross-platform defaults.
+Implementations§
Source§impl DnsResolver
Sourcepub fn new() -> DnsResolver
Creates a new resolver with sensible cross-platform defaults.
Equivalent to Builder::default().with_system_defaults().build().
See Builder::with_system_defaults for the per-platform
behavior, including the public DNS fallback that takes over
when the system reader returns nothing.
-The fallback can route queries through public providers
-(Cloudflare and Google). To keep DNS traffic on caller-supplied
-servers only, build the resolver through Self::builder
-with explicit nameservers.
-Sourcepub fn with_nameserver(nameserver: SocketAddr) -> DnsResolver
Creates a new DNS resolver configured with a single UDP DNS nameserver.
-Sourcepub fn builder() -> Builder
Creates a builder to construct a DNS resolver with custom options.
-Sourcepub fn custom(resolver: impl Resolver) -> DnsResolver
Creates a new DnsResolver from a struct that implements Resolver.
+The fallback routes queries through Google’s public DNS. To
+keep DNS traffic on caller-supplied servers only, build the
+resolver through Self::builder with explicit nameservers.
+Sourcepub fn with_nameserver(nameserver: SocketAddr) -> DnsResolver
Creates a new DNS resolver configured with a single UDP DNS nameserver.
+Sourcepub fn builder() -> Builder
Creates a builder to construct a DNS resolver with custom options.
+Sourcepub 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 fn clear_cache(&self)
Removes all entries from the cache.
-Sourcepub fn clear_cache(&self)
Removes all entries from the cache.
+Sourcepub fn reset(&self)
Replaces the inner resolver with a freshly-built one.
Call this on a major host network change to pick up the new system DNS
configuration and rebind sockets. The swap is atomic and non-blocking;
in-flight lookups retry against the new resolver. See Resolver::reset.
-Sourcepub async fn lookup_txt<T>(
+
Sourcepub 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>(
+
Sourcepub 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>(
+
Sourcepub 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>(
+
Sourcepub async fn lookup_ipv4_ipv6<T>(
&self,
host: T,
timeout: Duration,
@@ -50,13 +49,13 @@ in-flight lookups retry against the new resolver. See Sourcepub async fn resolve_host(
+
Sourcepub 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(
+
Sourcepub async fn lookup_ipv4_staggered(
&self,
host: impl ToString,
timeout: Duration,
@@ -66,7 +65,7 @@ individually.
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(
+
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
diff --git a/pr/4199/docs/iroh/dns/struct.DnsResolver.html b/pr/4199/docs/iroh/dns/struct.DnsResolver.html
index 25ffda972c..37342324cd 100644
--- a/pr/4199/docs/iroh/dns/struct.DnsResolver.html
+++ b/pr/4199/docs/iroh/dns/struct.DnsResolver.html
@@ -1,47 +1,46 @@
-DnsResolver in iroh::dns - Rust DnsResolver
pub struct DnsResolver { /* private fields */ }
Available on non-wasm_browser only.Expand description
The DNS resolver used throughout iroh.
+DnsResolver in iroh::dns - Rust DnsResolver
pub struct DnsResolver { /* private fields */ }
Available on non-wasm_browser only.Expand description
The DNS resolver used throughout iroh.
By default, we use a built-in resolver that reads the system’s DNS configuration.
The nameservers can be customized by constructing the resolver with Self::builder.
Alternatively, you can create a fully custom DNS resolver by implementing the Resolver
trait and creating the resolver with Self::custom.
-Implementations§
Source§impl DnsResolver
Sourcepub fn new() -> DnsResolver
Creates a new resolver with sensible cross-platform defaults.
+Implementations§
Source§impl DnsResolver
Sourcepub fn new() -> DnsResolver
Creates a new resolver with sensible cross-platform defaults.
Equivalent to Builder::default().with_system_defaults().build().
See Builder::with_system_defaults for the per-platform
behavior, including the public DNS fallback that takes over
when the system reader returns nothing.
-The fallback can route queries through public providers
-(Cloudflare and Google). To keep DNS traffic on caller-supplied
-servers only, build the resolver through Self::builder
-with explicit nameservers.
-Sourcepub fn with_nameserver(nameserver: SocketAddr) -> DnsResolver
Creates a new DNS resolver configured with a single UDP DNS nameserver.
-Sourcepub fn builder() -> Builder
Creates a builder to construct a DNS resolver with custom options.
-Sourcepub fn custom(resolver: impl Resolver) -> DnsResolver
Creates a new DnsResolver from a struct that implements Resolver.
+The fallback routes queries through Google’s public DNS. To
+keep DNS traffic on caller-supplied servers only, build the
+resolver through Self::builder with explicit nameservers.
+Sourcepub fn with_nameserver(nameserver: SocketAddr) -> DnsResolver
Creates a new DNS resolver configured with a single UDP DNS nameserver.
+Sourcepub fn builder() -> Builder
Creates a builder to construct a DNS resolver with custom options.
+Sourcepub 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 fn clear_cache(&self)
Removes all entries from the cache.
-Sourcepub fn clear_cache(&self)
Removes all entries from the cache.
+Sourcepub fn reset(&self)
Replaces the inner resolver with a freshly-built one.
Call this on a major host network change to pick up the new system DNS
configuration and rebind sockets. The swap is atomic and non-blocking;
in-flight lookups retry against the new resolver. See Resolver::reset.
-Sourcepub async fn lookup_txt<T>(
+
Sourcepub 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>(
+
Sourcepub 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>(
+
Sourcepub 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>(
+
Sourcepub async fn lookup_ipv4_ipv6<T>(
&self,
host: T,
timeout: Duration,
@@ -50,13 +49,13 @@ in-flight lookups retry against the new resolver. See Sourcepub async fn resolve_host(
+
Sourcepub 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(
+
Sourcepub async fn lookup_ipv4_staggered(
&self,
host: impl ToString,
timeout: Duration,
@@ -66,7 +65,7 @@ individually.
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(
+
DnsResolver
pub struct DnsResolver { /* private fields */ }wasm_browser only.Expand description
The DNS resolver used throughout iroh.
DnsResolver
pub struct DnsResolver { /* private fields */ }wasm_browser only.Expand description
The DNS resolver used throughout iroh.
By default, we use a built-in resolver that reads the system’s DNS configuration.
The nameservers can be customized by constructing the resolver with Self::builder.
Alternatively, you can create a fully custom DNS resolver by implementing the Resolver
trait and creating the resolver with Self::custom.
Implementations§
Source§impl DnsResolver
impl DnsResolver
Sourcepub fn new() -> DnsResolver
pub fn new() -> DnsResolver
Creates a new resolver with sensible cross-platform defaults.
+Implementations§
Source§impl DnsResolver
impl DnsResolver
Sourcepub fn new() -> DnsResolver
pub fn new() -> DnsResolver
Creates a new resolver with sensible cross-platform defaults.
Equivalent to Builder::default().with_system_defaults().build().
See Builder::with_system_defaults for the per-platform
behavior, including the public DNS fallback that takes over
when the system reader returns nothing.
The fallback can route queries through public providers
-(Cloudflare and Google). To keep DNS traffic on caller-supplied
-servers only, build the resolver through Self::builder
-with explicit nameservers.
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 builder() -> Builder
pub fn builder() -> Builder
Creates a builder to construct a DNS resolver with custom options.
-Sourcepub fn custom(resolver: impl Resolver) -> DnsResolver
pub fn custom(resolver: impl Resolver) -> DnsResolver
Creates a new DnsResolver from a struct that implements Resolver.
The fallback routes queries through Google’s public DNS. To
+keep DNS traffic on caller-supplied servers only, build the
+resolver through Self::builder with explicit nameservers.
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 builder() -> Builder
pub fn builder() -> Builder
Creates a builder to construct a DNS resolver with custom options.
+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 fn clear_cache(&self)
pub fn clear_cache(&self)
Removes all entries from the cache.
-Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Removes all entries from the cache.
+Sourcepub fn reset(&self)
pub fn reset(&self)
Replaces the inner resolver with a freshly-built one.
Call this on a major host network change to pick up the new system DNS
configuration and rebind sockets. The swap is atomic and non-blocking;
in-flight lookups retry against the new resolver. See Resolver::reset.
Sourcepub async fn lookup_txt<T>(
+
pub async fn lookup_txt<T>( +
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>(
+
pub async fn lookup_ipv4<T>( +
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>(
+
pub async fn lookup_ipv6<T>( +
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>(
+
pub async fn lookup_ipv4_ipv6<T>( +
Sourcepub async fn lookup_ipv4_ipv6<T>(
&self,
host: T,
timeout: Duration,
@@ -50,13 +49,13 @@ in-flight lookups retry against the new resolver. See Sourcepub async fn resolve_host(
+
pub async fn lookup_ipv4_ipv6<T>(
&self,
host: T,
timeout: Duration,
@@ -50,13 +49,13 @@ in-flight lookups retry against the new resolver. See Sourcepub async fn resolve_host(
+
pub async fn resolve_host( +
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.
-