pub struct ResolverConfig { /* private fields */ }
Expand description

Configuration for the upstream nameservers to use for resolution

Implementations

Creates a new empty configuration

Creates a default configuration, using 8.8.8.8, 8.8.4.4 and 2001:4860:4860::8888, 2001:4860:4860::8844 (thank you, Google).

Please see Google’s privacy statement for important information about what they track, many ISP’s track similar information in DNS. To use the system configuration see: Resolver::from_system_conf and AsyncResolver::from_system_conf

NameServerConfigGroups can be combined to use a set of different providers, see NameServerConfigGroup and ResolverConfig::from_parts

Creates a default configuration, using 1.1.1.1, 1.0.0.1 and 2606:4700:4700::1111, 2606:4700:4700::1001 (thank you, Cloudflare).

Please see: https://www.cloudflare.com/dns/

NameServerConfigGroups can be combined to use a set of different providers, see NameServerConfigGroup and ResolverConfig::from_parts

Available on crate feature dns-over-tls only.

Creates a configuration, using 1.1.1.1, 1.0.0.1 and 2606:4700:4700::1111, 2606:4700:4700::1001 (thank you, Cloudflare). This limits the registered connections to just TLS lookups

Please see: https://www.cloudflare.com/dns/

NameServerConfigGroups can be combined to use a set of different providers, see NameServerConfigGroup and ResolverConfig::from_parts

Available on crate feature dns-over-https only.

Creates a configuration, using 1.1.1.1, 1.0.0.1 and 2606:4700:4700::1111, 2606:4700:4700::1001 (thank you, Cloudflare). This limits the registered connections to just HTTPS lookups

Please see: https://www.cloudflare.com/dns/

NameServerConfigGroups can be combined to use a set of different providers, see NameServerConfigGroup and ResolverConfig::from_parts

Creates a configuration, using 9.9.9.9, 149.112.112.112 and 2620:fe::fe, 2620:fe::fe:9, the “secure” variants of the quad9 settings (thank you, Quad9).

Please see: https://www.quad9.net/faq/

NameServerConfigGroups can be combined to use a set of different providers, see NameServerConfigGroup and ResolverConfig::from_parts

Available on crate feature dns-over-tls only.

Creates a configuration, using 9.9.9.9, 149.112.112.112 and 2620:fe::fe, 2620:fe::fe:9, the “secure” variants of the quad9 settings. This limits the registered connections to just TLS lookups

Please see: https://www.quad9.net/faq/

NameServerConfigGroups can be combined to use a set of different providers, see NameServerConfigGroup and ResolverConfig::from_parts

Available on crate feature dns-over-https only.

Creates a configuration, using 9.9.9.9, 149.112.112.112 and 2620:fe::fe, 2620:fe::fe:9, the “secure” variants of the quad9 settings. This limits the registered connections to just HTTPS lookups

Please see: https://www.quad9.net/faq/

NameServerConfigGroups can be combined to use a set of different providers, see NameServerConfigGroup and ResolverConfig::from_parts

Create a ResolverConfig with all parts specified

Arguments
  • domain - domain of the entity querying results. If the Name being looked up is not an FQDN, then this is the first part appended to attempt a lookup. ndots in the ResolverOption does take precedence over this.
  • search - additional search domains that are attempted if the Name is not found in domain, defaults to vec![]
  • name_servers - set of name servers to use for lookups, defaults are Google: 8.8.8.8, 8.8.4.4 and 2001:4860:4860::8888, 2001:4860:4860::8844

Returns the local domain

By default any names will be appended to all non-fully-qualified-domain names, and searched for after any ndots rules

Set the domain of the entity querying results.

Returns the search domains

These will be queried after any local domain and then in the order of the set of search domains

Add a search domain

Add the configuration for a name server

Returns a reference to the name servers

Available on crate feature dns-over-rustls only.

return the associated TlsClientConfig

Available on crate feature dns-over-rustls only.

adds the rustls::ClientConf for every configured NameServer of the Resolver.

use std::sync::Arc;

use rustls::{ClientConfig, ProtocolVersion, RootCertStore, OwnedTrustAnchor};
use trust_dns_resolver::config::ResolverConfig;
use webpki_roots;

let mut root_store = RootCertStore::empty();
root_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
    OwnedTrustAnchor::from_subject_spki_name_constraints(
        ta.subject,
        ta.spki,
        ta.name_constraints,
    )
}));

let mut client_config = ClientConfig::builder()
    .with_safe_default_cipher_suites()
    .with_safe_default_kx_groups()
    .with_protocol_versions(&[&rustls::version::TLS12])
    .unwrap()
    .with_root_certificates(root_store)
    .with_no_client_auth();

let mut resolver_config = ResolverConfig::quad9_tls();
resolver_config.set_tls_client_config(Arc::new(client_config));

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Creates a default configuration, using 8.8.8.8, 8.8.4.4 and 2001:4860:4860::8888, 2001:4860:4860::8844 (thank you, Google).

Please see Google’s privacy statement for important information about what they track, many ISP’s track similar information in DNS. To use the system configuration see: Resolver::from_system_conf and AsyncResolver::from_system_conf

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

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

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

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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