we (web engine): Experimental web browser project to understand the limits of Claude

DNS stub resolver (UDP, A/AAAA records) #58

open opened by pierrelf.com

Phase 6: DNS Stub Resolver#

Implement a minimal DNS stub resolver in the net crate for resolving hostnames to IP addresses.

Requirements#

  • DNS message format (RFC 1035):
    • Header: ID, flags (QR, OPCODE, RD), QDCOUNT, ANCOUNT
    • Question section: QNAME, QTYPE, QCLASS
    • Answer section: NAME (with compression pointer support), TYPE, CLASS, TTL, RDATA
  • Query types: A (IPv4) and AAAA (IPv6) records
  • Transport: UDP via std::net::UdpSocket (port 53)
  • System resolver config: parse /etc/resolv.conf to find nameserver addresses
  • Resolution function: resolve(hostname: &str) -> Result<Vec<IpAddr>>
    • Send A and AAAA queries
    • Parse responses and collect IP addresses
    • Timeout handling (2-3 second default)
    • Retry logic (try next nameserver on failure)
  • DNS name encoding: labels with length prefix, domain compression pointer handling

Dependencies#

  • std::net::UdpSocket (standard library)
  • TCP socket wrapper (for TCP fallback on truncated responses — optional, can defer)

Acceptance Criteria#

  • Build and serialize DNS query messages
  • Parse DNS response messages with A and AAAA records
  • Handle name compression pointers in responses
  • Read nameserver from /etc/resolv.conf
  • Resolve real hostnames to IP addresses
  • Timeout and retry handling
  • Comprehensive tests for message serialization/parsing (20+ tests)
  • cargo clippy and cargo fmt clean
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mguykga7sj2e