CNAME and common types
Decode A, AAAA, NS, MX, and TXT, and follow CNAME with a hop limit.
CNAME and common types
Decode A, AAAA, NS, MX, and TXT, and follow CNAME with a hop limit. Keep the capabilities from earlier stages working.
Observable contract
The harness uses JSON and represents DNS packets as lowercase hexadecimal. Network exchanges are modelled with responses supplied in the request so assessment stays deterministic.
{
"op": "resolve-chain",
"name": "www.example.test",
"answers": [
{
"type": "CNAME",
"name": "www.example.test",
"target": "origin.example.test"
},
{ "type": "A", "name": "origin.example.test", "address": "192.0.2.10" }
]
}
must produce exactly:
{ "canonical": "origin.example.test", "addresses": ["192.0.2.10"] }
Output is compact JSON followed by a newline. Invalid input leaves stdout empty, writes a diagnostic containing error to stderr, and exits non-zero.
Implementation
Keep encoding, validation, and traversal separate. Check every length before advancing the cursor, interpret integers in network byte order, and bound all pointer or reference following. Fixtures replace transport only: the logic must later be reusable with real UDP.
Also test truncated packets, overlong labels, out-of-range offsets, and cycles. Do not use the system DNS resolver for the mechanism taught in this stage.
Acceptance criteria
- The example matches byte for byte.
- Malformed data fails in a controlled way.
- Record and result ordering is deterministic.