Skip to main content

Module dns

Module dns 

Source
Expand description

DNS resolution and caching.

Every verifier resolves DNS records through the backend wrapped by MessageAuthenticator. Exactly one backend is compiled in:

  • dns-hickory (default): UDP, TCP or DNS-over-TLS queries through hickory-resolver. Not available on WebAssembly.
  • dns-doh: DNS-over-HTTPS queries (RFC 8484) through DohResolver, using either the JSON API or the DNS wire format. Works on WebAssembly.

Lookups can be cached. A cache is supplied per call by wrapping the verifier input in Parameters with Parameters::with_cache. The cache type implements DnsCache, which hands out one ResolverCache per record type (TXT, MX, A, AAAA and PTR). TXT records are cached already parsed, as TxtRecord values. NoCache disables caching and is the default.

Negative answers (RFC 2308) are cached too: a name that does not exist (NXDOMAIN) or has no records of the requested type (NODATA) is stored as TxtRecord::Error in the TXT cache and as Err(Negative) in the other caches, until the negative TTL of the answer expires. That TTL is the SOA-derived value of RFC 2308 Section 5, capped by MessageAuthenticator::with_max_negative_ttl. Answers without an SOA record and resolver failures are never cached.

The lookup helpers on MessageAuthenticator (txt_lookup, mx_lookup, ipv4_lookup, ipv6_lookup, ip_lookup, ptr_lookup, exists) are public so that applications can reuse the resolver and caches for their own queries.

Re-exports§

pub use cache::DnsCache;
pub use cache::NoCache;
pub use cache::Parameters;
pub use cache::ResolverCache;
pub use txt::TxtRecord;
pub use txt::TxtRecordParser;

Modules§

cache
DNS cache traits and the per-call Parameters wrapper.

Structs§

DnsEntry
A raw DNS answer together with the time at which it expires, as returned by MessageAuthenticator::ipv4_lookup_raw and MessageAuthenticator::ipv6_lookup_raw.
Mx
A group of MX records (RFC 5321 Section 5.1) that share a preference value.
Negative
A cached negative answer (RFC 2308): the name does not exist (NXDOMAIN), or it has no records of the requested type (NODATA).
RecordSet
The records returned by a DNS lookup, as stored in a ResolverCache.

Enums§

DnssecStatus
DNSSEC validation state of a DNS answer (RFC 4035 Section 4.3).
IpLookupStrategy
Address families queried by MessageAuthenticator::ip_lookup, and in which order.
TxtRecord
A parsed DNS TXT record, as stored in the TXT ResolverCache of a DnsCache.

Traits§

ToFqdn
Conversion of a domain name to the fully qualified form used as a DNS query and cache key.
ToReverseName
Conversion of an IP address to the label sequence of its reverse DNS name.
TxtRecordParser
Parser for a record type published in DNS TXT records.

Functions§

has_valid_labels
Returns true if domain looks like a valid host name for a DNS query.