Small shared helpers used by both dns.client and dns.iter: numeric/string qtype resolution, query-message building (RD and DO bits parameterized), response validation, and SOA extraction. Kept here so the two resolvers can't drift on wire-format details.
| Name | Signature |
|---|---|
resolve_qtype | resolve_qtype(qtype) -> code, err |
build_query | build_query(qname, qtype, id, opts) -> msg |
validate_response | validate_response(resp, id, qname, qtype, sent_0x20_name) -> ok, err |
extract_soa | extract_soa(authority) -> soa |
resolve_qtype(
qtype) ->code,err
Resolve a qtype to a numeric code
Accepts a numeric code directly, a known mnemonic ("A", "AAAA", case
insensitive), or a numeric string ("48"). Returns nil, err for
unknown strings or non-string/number inputs.
build_query(
qname,qtype,id,opts) ->msg
Build a DNS query message table (not wire-encoded)
Returns a message table ready to pass to message.encode(). Options:
edns_buffer_size — when set, attach an EDNS OPT RR with this UDP
payload size. Omit (or pass nil/false) to build a bare RFC1035 query.
rd — Recursion Desired flag (default true for recursive resolvers;
set false for iterative queries).
do_bit — EDNS DNSSEC OK bit. Only meaningful when edns_buffer_size
is set (default false).
validate_response(
resp,id,qname,qtype,sent_0x20_name) ->ok,err
Validate a decoded DNS response against the original query
Checks that the response matches the query we sent: ID match, a question
section with matching qtype and name. If sent_0x20_name is non-nil,
the response name is verified against the 0x20-encoded original
(case-preserving); otherwise a case-insensitive name comparison is used.
extract_soa(
authority) ->soa
Extract the first SOA record from an authority section