dns.helpers — Lilush API

←index

← dns

Overview

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.

Functions

NameSignature
resolve_qtyperesolve_qtype(qtype) -> code, err
build_querybuild_query(qname, qtype, id, opts) -> msg
validate_responsevalidate_response(resp, id, qname, qtype, sent_0x20_name) -> ok, err
extract_soaextract_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:

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