Struct trust_dns_resolver::config::ResolverConfig
source · [−]pub struct ResolverConfig { /* private fields */ }
Expand description
Configuration for the upstream nameservers to use for resolution
Implementations
sourceimpl ResolverConfig
impl ResolverConfig
sourcepub fn google() -> Self
pub fn google() -> Self
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
sourcepub fn cloudflare() -> Self
pub fn cloudflare() -> Self
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
sourcepub fn cloudflare_tls() -> Self
This is supported on crate feature dns-over-tls
only.
pub fn cloudflare_tls() -> Self
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
sourcepub fn cloudflare_https() -> Self
This is supported on crate feature dns-over-https
only.
pub fn cloudflare_https() -> Self
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
sourcepub fn quad9() -> Self
pub fn quad9() -> Self
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
sourcepub fn quad9_tls() -> Self
This is supported on crate feature dns-over-tls
only.
pub fn quad9_tls() -> Self
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
sourcepub fn quad9_https() -> Self
This is supported on crate feature dns-over-https
only.
pub fn quad9_https() -> Self
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
sourcepub fn from_parts<G: Into<NameServerConfigGroup>>(
domain: Option<Name>,
search: Vec<Name>,
name_servers: G
) -> Self
pub fn from_parts<G: Into<NameServerConfigGroup>>(
domain: Option<Name>,
search: Vec<Name>,
name_servers: G
) -> Self
Create a ResolverConfig with all parts specified
Arguments
domain
- domain of the entity querying results. If theName
being looked up is not an FQDN, then this is the first part appended to attempt a lookup.ndots
in theResolverOption
does take precedence over this.search
- additional search domains that are attempted if theName
is not found indomain
, defaults tovec![]
name_servers
- set of name servers to use for lookups, defaults are Google:8.8.8.8
,8.8.4.4
and2001:4860:4860::8888
,2001:4860:4860::8844
sourcepub fn domain(&self) -> Option<&Name>
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
sourcepub fn set_domain(&mut self, domain: Name)
pub fn set_domain(&mut self, domain: Name)
Set the domain of the entity querying results.
sourcepub fn search(&self) -> &[Name]
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
sourcepub fn add_search(&mut self, search: Name)
pub fn add_search(&mut self, search: Name)
Add a search domain
sourcepub fn add_name_server(&mut self, name_server: NameServerConfig)
pub fn add_name_server(&mut self, name_server: NameServerConfig)
Add the configuration for a name server
sourcepub fn name_servers(&self) -> &[NameServerConfig]
pub fn name_servers(&self) -> &[NameServerConfig]
Returns a reference to the name servers
sourcepub fn client_config(&self) -> &Option<TlsClientConfig>
This is supported on crate feature dns-over-rustls
only.
pub fn client_config(&self) -> &Option<TlsClientConfig>
dns-over-rustls
only.return the associated TlsClientConfig
sourcepub fn set_tls_client_config(&mut self, client_config: Arc<ClientConfig>)
This is supported on crate feature dns-over-rustls
only.
pub fn set_tls_client_config(&mut self, client_config: Arc<ClientConfig>)
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
sourceimpl Clone for ResolverConfig
impl Clone for ResolverConfig
sourcefn clone(&self) -> ResolverConfig
fn clone(&self) -> ResolverConfig
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ResolverConfig
impl Debug for ResolverConfig
sourceimpl Default for ResolverConfig
impl Default for ResolverConfig
sourcefn default() -> Self
fn default() -> Self
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
sourceimpl<'de> Deserialize<'de> for ResolverConfig
impl<'de> Deserialize<'de> for ResolverConfig
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl PartialEq<ResolverConfig> for ResolverConfig
impl PartialEq<ResolverConfig> for ResolverConfig
sourcefn eq(&self, other: &ResolverConfig) -> bool
fn eq(&self, other: &ResolverConfig) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ResolverConfig) -> bool
fn ne(&self, other: &ResolverConfig) -> bool
This method tests for !=
.
sourceimpl Serialize for ResolverConfig
impl Serialize for ResolverConfig
impl Eq for ResolverConfig
impl StructuralEq for ResolverConfig
impl StructuralPartialEq for ResolverConfig
Auto Trait Implementations
impl !RefUnwindSafe for ResolverConfig
impl Send for ResolverConfig
impl Sync for ResolverConfig
impl Unpin for ResolverConfig
impl !UnwindSafe for ResolverConfig
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more