Implement iterative DNS resolver #1

Closed
opened 2026-02-19 22:42:18 +01:00 by clawbot · 0 comments
Collaborator

Plan

Implement the iterative DNS resolution engine in internal/resolver/resolver.go.

Requirements

  1. Hardcode IANA root nameserver IPs (IPv4+IPv6) with periodic refresh
  2. Iterative resolution: root → TLD → domain → authoritative
  3. LookupNS(ctx, domain) — trace delegation chain for authoritative NSes
  4. LookupAllRecords(ctx, hostname) — query each authoritative NS independently for A, AAAA, CNAME, MX, TXT, SRV, CAA, NS. Return map[nameserver]map[recordType][]string
  5. ResolveIPAddresses(ctx, hostname) — resolve to all IPs following CNAME chains (depth limit 10)
  6. Use github.com/miekg/dns for wire protocol
  7. Timeouts, retries (2 per query), SERVFAIL/REFUSED/NXDOMAIN handling
  8. UDP with TCP fallback for truncated responses
  9. Thread-safe

Approach

  • TDD: write tests first, commit, then implement
  • Tests use real DNS against example.com, google.com
  • Run make check before commits
## Plan Implement the iterative DNS resolution engine in `internal/resolver/resolver.go`. ### Requirements 1. Hardcode IANA root nameserver IPs (IPv4+IPv6) with periodic refresh 2. Iterative resolution: root → TLD → domain → authoritative 3. `LookupNS(ctx, domain)` — trace delegation chain for authoritative NSes 4. `LookupAllRecords(ctx, hostname)` — query each authoritative NS independently for A, AAAA, CNAME, MX, TXT, SRV, CAA, NS. Return `map[nameserver]map[recordType][]string` 5. `ResolveIPAddresses(ctx, hostname)` — resolve to all IPs following CNAME chains (depth limit 10) 6. Use `github.com/miekg/dns` for wire protocol 7. Timeouts, retries (2 per query), SERVFAIL/REFUSED/NXDOMAIN handling 8. UDP with TCP fallback for truncated responses 9. Thread-safe ### Approach - TDD: write tests first, commit, then implement - Tests use real DNS against example.com, google.com - Run `make check` before commits
sneak was assigned by clawbot 2026-02-19 22:42:18 +01:00
clawbot added the
merge-ready
label 2026-02-20 09:28:58 +01:00
sneak closed this issue 2026-02-20 19:37:59 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sneak/dnswatcher#1
No description provided.