The finale drives the whole resolver against a scripted root, .com, and authoritative server to resolve www.example.com from nothing but a root address - echoing the query ID, honoring the RCODE, and returning the real answer. Every layer proves itself at once.
Resolve www.example.com end to end through scripted nameserver responses.
This is the promise the whole project was built to keep: a working DNS
resolver. The capstone assembles a complete delegation as scripted responses - a
root server that refers to .com, a .com server that refers to example.com’s
authoritative server, and an authoritative server that answers with the address -
and then lets your resolver walk it from a single root address to the final A
record 93.184.216.34. Every piece you built runs at once: the query is encoded to
exact bytes, each response is parsed with compression and record decoding, the ID
is checked on every hop, the referral reader picks the next server from glue, and
the RCODE decides success or failure.
Swap the authoritative reply for an NXDOMAIN and the same code returns an error instead of an address, proving the status handling is real and not decoration. From a single big-endian helper you have built the honest core of a resolver - the wire format, name compression, every common record type, and the iterative root-to-authoritative algorithm - the same design that sits inside Unbound and BIND, minus the live sockets, caching, and DNSSEC they layer on top. That is a real resolver, and it is yours.
root := scriptedRoot() // refers .comtld := scriptedCom() // refers example.comauth := scriptedAuth() // answers A 93.184.216.34r := &Resolver{dial: dialFor(root, tld, auth)}got, err := r.resolve("www.example.com") // "93.184.216.34"