nx_dns.nx
buildroot/runtime/nx_dns.nx
about
nx_dns.nx -- sovereign DNS stub-resolver primitives (RFC 1035).
Phase 0a of the Nishi browser per docs/NISHI_BROWSER_ROADMAP.md.
The deepest missing L2 dependency between nx_udp (shipped) and
nx_http_client (shipped) on the way to a sovereign GET against an
arbitrary hostname. Pure parse/build primitives -- no syscalls,
no allocation beyond the caller's buffer, architecture-clean so
the self-test runs under qemu-riscv64 via nx_smoke_lib.
Live network resolve composes against nx_udp in a separate
nx_dns_io.nx (queued) so this file stays portable.
What it does today:
- encode a domain name into RFC 1035 label-length wire format
- build a query packet (header + question, RD bit set)
- parse a response and extract the first IPv4 A record
- skip a name with BOUNDED pointer-decompression per
[[feedback-bounded-loop-discipline-jpl-rule-2]] -- no infinite
loop on a crafted self-referential pointer
- sealed verdict enum with NX_DNS_VERDICT_N validity gate
What it doesn't do yet:
- IPv6 AAAA extraction (constants present; helper queued)
- CNAME chase (caller-level retry for v1)
- Truncation (TC=1) -> TCP fallback (Phase 0b)
- EDNS0 OPT record (Phase 0c)
- DNSSEC validation per RFC 4035 (queued separate phase)
- DoH / DoT (queued once nx_tls13 audit completes)
Composes with:
- nx_udp (transport for live resolve, in nx_dns_io.nx)
- nx_csprng (caller supplies tx_id from nx_csprng_u64 per RFC 5452
off-path spoof defense)
- nx_http_client (replaces its "caller packs IPv4 manually" gap
once nx_dns_io.nx wires the chain end-to-end)
license_tier: INDEPENDENT_REDERIVE
genealogy_id: international-research-sources/ietf/rfc_1035 + ietf/rfc_5452
lineage_id: nishi_browser_dns_stub_resolver_q10
dependencies 0 imports · 13 importers
diagram shows first 10 each side; +0 more imports, +3 more importers in the complete lists below.
imports: none
imported by: _inet_fetch_authored.nxnx_acme_dns01_propagation.nxnx_dns_authoritative.nxnx_dns_client_probe.nxnx_dns_io.nxnx_dns_resolve_a_record.nxnx_dns_test.nxnx_dns_txt.nxnx_email_mx.nxnx_mdns.nxnx_mdns_test.nxnx_netscope_dissect.nxnx_netscope_dns.nx
structs
| none |
consts
| 67 | const NX_DNS_VERDICT_UNKNOWN: i64 = 0 |
| 68 | const NX_DNS_VERDICT_OK: i64 = 1 |
| 69 | const NX_DNS_VERDICT_BUF_TOO_SMALL: i64 = 2 |
| 70 | const NX_DNS_VERDICT_BAD_HEADER: i64 = 3 |
| 71 | const NX_DNS_VERDICT_BAD_LABEL: i64 = 4 |
| 72 | const NX_DNS_VERDICT_PTR_LOOP: i64 = 5 |
| 73 | const NX_DNS_VERDICT_PTR_OUT_OF_RANGE: i64 = 6 |
| 74 | const NX_DNS_VERDICT_TXID_MISMATCH: i64 = 7 |
| 75 | const NX_DNS_VERDICT_NOT_RESPONSE: i64 = 8 |
| 76 | const NX_DNS_VERDICT_TRUNCATED: i64 = 9 |
| 77 | const NX_DNS_VERDICT_RCODE_NONZERO: i64 = 10 |
| 78 | const NX_DNS_VERDICT_NO_A_RECORD: i64 = 11 |
| 79 | const NX_DNS_VERDICT_N: i64 = 12 |
| 82 | const NX_DNS_PORT: i64 = 53 |
| 83 | const NX_DNS_HEADER_LEN: i64 = 12 |
| 84 | const NX_DNS_TYPE_A: i64 = 1 |
| 85 | const NX_DNS_TYPE_NS: i64 = 2 |
| 86 | const NX_DNS_TYPE_CNAME: i64 = 5 |
| 87 | const NX_DNS_TYPE_SOA: i64 = 6 |
| 88 | const NX_DNS_TYPE_PTR: i64 = 12 |
| 89 | const NX_DNS_TYPE_MX: i64 = 15 |
| 90 | const NX_DNS_TYPE_TXT: i64 = 16 |
| 91 | const NX_DNS_TYPE_AAAA: i64 = 28 |
| 92 | const NX_DNS_CLASS_IN: i64 = 1 |
| 95 | const NX_DNS_FLAG_QR: i64 = 0x8000 // 1 = response |
| 96 | const NX_DNS_FLAG_TC: i64 = 0x0200 // 1 = truncated |
| 97 | const NX_DNS_FLAG_RD: i64 = 0x0100 // 1 = recursion desired |
| 98 | const NX_DNS_FLAG_RA: i64 = 0x0080 // 1 = recursion available |
| 99 | const NX_DNS_RCODE_MASK: i64 = 0x000f |
| 106 | const NX_DNS_MAX_PTR_HOPS: i64 = 128 |
| 111 | const NX_DNS_MAX_RECORDS: i64 = 64 |
functions
| 115 | func nx_dns_put_u16_be(out: *u8, o: i64, v: i64) -> i64 |
| 121 | func nx_dns_get_u16_be(buf: *u8, o: i64) -> i64 |
| 127 | func nx_dns_get_u32_be(buf: *u8, o: i64) -> i64 |
| 144 | func nx_dns_encode_name(name: *u8, name_len: i64, out: *u8, out_cap: i64) -> i64 |
| 188 | func nx_dns_skip_name(buf: *u8, n: i64, start: i64) -> i64 |
| 255 | func nx_dns_build_query( |
| 286 | func nx_dns_parse_response_a( |
| 340 | func nx_dns_verdict_is_valid(v: i64) -> i64 called by 1: main |