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

Configuration for the upstream nameservers to use for resolution

Implementations§

source§

impl ResolverConfig

source

pub fn new() -> ResolverConfig

Creates a new empty configuration

source

pub fn google() -> ResolverConfig

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

source

pub fn cloudflare() -> ResolverConfig

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

source

pub fn cloudflare_tls() -> ResolverConfig

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

source

pub fn cloudflare_https() -> ResolverConfig

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

source

pub fn quad9() -> ResolverConfig

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

source

pub fn quad9_tls() -> ResolverConfig

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

source

pub fn quad9_https() -> ResolverConfig

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

source

pub fn from_parts<G>( domain: Option<Name>, search: Vec<Name, Global>, name_servers: G ) -> ResolverConfigwhere G: Into<NameServerConfigGroup>,

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
source

pub fn domain(&self) -> Option<&Name>

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

source

pub fn set_domain(&mut self, domain: Name)

Set the domain of the entity querying results.

source

pub fn search(&self) -> &[Name]

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

source

pub fn add_name_server(&mut self, name_server: NameServerConfig)

Add the configuration for a name server

source

pub fn name_servers(&self) -> &[NameServerConfig]

Returns a reference to the name servers

source

pub fn client_config(&self) -> &Option<TlsClientConfig>

Available on crate feature dns-over-rustls only.

return the associated TlsClientConfig

source

pub fn set_tls_client_config(&mut self, client_config: Arc<ClientConfig>)

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§

source§

impl Clone for ResolverConfig

source§

fn clone(&self) -> ResolverConfig

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 ResolverConfig

source§

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

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

impl Default for ResolverConfig

source§

fn default() -> ResolverConfig

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

source§

impl PartialEq<ResolverConfig> for ResolverConfig

source§

fn eq(&self, other: &ResolverConfig) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

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

impl Eq for ResolverConfig

source§

impl StructuralEq for ResolverConfig

source§

impl StructuralPartialEq for ResolverConfig

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

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

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

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

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

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 Twhere U: From<T>,

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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