pub struct Builder { /* private fields */ }Expand description
Builder for DnsResolver.
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn with_system_defaults(self) -> Self
pub fn with_system_defaults(self) -> Self
Makes the builder respect the host system’s DNS configuration.
The configuration is read in a platform-specific way. If that fails, or
if it lists no nameservers, the fallback tier answers instead, subject
to the FallbackMode.
Sourcepub fn with_nameserver(self, addr: SocketAddr, protocol: DnsProtocol) -> Self
👎Deprecated since 1.2.0: use add_nameserver_config()
pub fn with_nameserver(self, addr: SocketAddr, protocol: DnsProtocol) -> Self
Adds a single nameserver config.
For DNS-over-TLS and DNS-over-HTTPS, the server name is inferred from the
IP address. To set a different one, build a NameserverConfig with
NameserverConfig::with_tls_server_name and pass it to
Self::add_nameserver_config.
Sourcepub fn with_nameservers(
self,
nameservers: impl IntoIterator<Item = (SocketAddr, DnsProtocol)>,
) -> Self
👎Deprecated since 1.2.0: use add_nameserver_configs()
pub fn with_nameservers( self, nameservers: impl IntoIterator<Item = (SocketAddr, DnsProtocol)>, ) -> Self
Adds a list of nameserver configs.
For DNS-over-TLS and DNS-over-HTTPS, the server name is inferred from the
IP address. To set a different one, build a NameserverConfig with
NameserverConfig::with_tls_server_name and pass it to
Self::add_nameserver_configs.
Sourcepub fn add_nameserver_config(self, nameserver: NameserverConfig) -> Self
pub fn add_nameserver_config(self, nameserver: NameserverConfig) -> Self
Adds a single nameserver config.
Sourcepub fn add_nameserver_configs(
self,
nameservers: impl IntoIterator<Item = NameserverConfig>,
) -> Self
pub fn add_nameserver_configs( self, nameservers: impl IntoIterator<Item = NameserverConfig>, ) -> Self
Adds a list of nameserver configs.
Sourcepub fn tls_client_config(self, client_config: ClientConfig) -> Self
pub fn tls_client_config(self, client_config: ClientConfig) -> Self
Sets a custom TLS client configuration.
This overrides the default configuration used for DNS-over-TLS and DNS-over-HTTPS.
When neither the tls-ring nor tls-aws-lc-rs feature is enabled,
DNS-over-TLS and DNS-over-HTTPS require a custom configuration containing
a crypto provider, supplied with Self::tls_client_config.
Sourcepub fn with_fallback_mode(self, mode: FallbackMode) -> Self
pub fn with_fallback_mode(self, mode: FallbackMode) -> Self
Sets how the fallback nameservers are used relative to the primary ones.
The default is FallbackMode::Deferred: the fallback nameservers are a
lower-priority tier, queried only when the primary nameservers fail or
time out. See FallbackMode for the other modes.
Sourcepub fn disable_fallback(self) -> Self
pub fn disable_fallback(self) -> Self
Disables the fallback nameservers, so only the primary ones are queried.
Shorthand for Self::with_fallback_mode with FallbackMode::Never.
Sourcepub fn fallback_nameserver_configs(
self,
nameservers: impl IntoIterator<Item = NameserverConfig>,
) -> Self
pub fn fallback_nameserver_configs( self, nameservers: impl IntoIterator<Item = NameserverConfig>, ) -> Self
Adds nameservers to the fallback tier, in place of the default ones.
Appends, so it can be called repeatedly. Adding any nameserver here
replaces the default public resolvers, which are only used when this
list is left empty. Has no effect when the fallback mode is
FallbackMode::Never.
Sourcepub fn build(self) -> DnsResolver
pub fn build(self) -> DnsResolver
Builds the DNS resolver.