Skip to main content

Module doh

Module doh 

Source
Expand description

DNS over HTTPS, for the records a stub resolver has no API for: a zone’s nameservers, a handle’s TXT record, a lexicon authority’s TXT record.

RFC 8484 carries DNS’s own wire format over HTTPS. Cloudflare’s and Google’s resolvers also answer a JSON sibling of it: a GET naming the record and its type, answered as application/dns-json. That JSON form is what this speaks. query_url and parse need no network, and lookup makes the request through crate::pinned_client.

Whoever runs the resolver sees every name asked of it, so every caller takes the resolver’s address as a parameter.

Constants§

CLOUDFLARE
Cloudflare’s resolver, which answers the JSON form.
JSON_ACCEPT
The Accept header that asks a DoH endpoint for JSON rather than the wire format.
MAX_ANSWER_BYTES
The most of one answer lookup reads. A TXT answer is a few hundred bytes.
TXT
The TXT record type, by its number and its name.

Functions§

escape 🔒
Percent-encodes what a hostname may legitimately carry and a query string may not. A hostname is letters, digits, hyphens, dots and underscores (_atproto), so this is a narrow guard against a caller’s typo reaching the resolver as query syntax rather than a general encoder.
lookup
The records of record_type, by number and name, at name, as the resolver at resolver answers: one GET through a client pinned to the resolver’s own addresses, its answer read under MAX_ANSWER_BYTES and by parse.
parse
Reads one answer: the records of type record_type, as strings.
query_url
The URL one query is made at.
status_name 🔒
The DNS RCODEs a public resolver actually answers with, by name.
tidy 🔒
A record’s data as a caller wants to read it: a nameserver without its root dot, a TXT record with its character-string quoting undone, and anything else as it came.