Karta. DNS. Resolver. Unbound
(Karta v1.0.0)
Looks names up through a recursive, DNSSEC-validating resolver (Unbound), over UDP with a fallback to TCP when the answer is truncated.
Trust boundary
Karta.DNS.Answer.secure is the AD bit of the resolver's response. Karta
does not validate signatures itself; it believes the resolver. That is
only sound when the resolver validates and nobody can alter the traffic
between Karta and the resolver (RFC 6698 §4.1, RFC 7672 §2.1.1): run
Unbound on the same host (loopback) or as a sidecar on a network no other
container or host shares.
Therefore the AD bit is believed only from a loopback address unless the
configuration says trust_ad: true. From any other address every answer
is reported with secure: false, which makes DANE ignore TLSA records
rather than trust them.
Defences against forged responses
- a new socket per attempt, bound to port 0, so every query has its own source port chosen by the operating system (ephemeral ports are randomised by Linux and the BSDs); the socket is connected, so the kernel drops datagrams from other addresses;
- a random 16-bit query id from
:crypto.strong_rand_bytes/1; - a response is used only if it comes from the server's address and port, decodes, is a response (QR) to a standard query with our id, and repeats our question exactly (name ignoring case, type, class); anything else is ignored and the wait continues until the timeout.
Options
:server-{ip, port}of the resolver (default{{127, 0, 0, 1}, 53}):trust_ad- believe the AD bit (default: only for a loopback server):timeout- milliseconds per attempt (default 2000):attempts- UDP attempts before giving up (default 2):udp_size- the EDNS(0) UDP payload size Karta offers (default 1232)
Summary
Functions
Sends one query and returns the validated response and the transport
that carried it (:udp, or :tcp after a truncated UDP answer).
True when the AD bit from this resolver is believed (see the module doc).
Functions
@spec query(String.t(), Karta.DNS.Record.type(), keyword()) :: {:ok, Karta.DNS.Message.t(), :udp | :tcp} | {:error, Karta.DNS.Resolver.error()}
Sends one query and returns the validated response and the transport
that carried it (:udp, or :tcp after a truncated UDP answer).
True when the AD bit from this resolver is believed (see the module doc).