code wiki / (root) / nx_dns.nx

nx_dns.nx

buildroot/runtime/nx_dns.nx

13945 B344 linesdepth 0pulls 0 transitivereach 530 importersview sourcekind librarytopic dns
docsdependenciesstructsconstsfunctions

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

nx_dns.nx _inet_fetch_authored.nx nx_acme_dns01_propagation.nx nx_dns_authoritative.nx nx_dns_client_probe.nx nx_dns_io.nx nx_dns_resolve_a_record.nx nx_dns_test.nx nx_dns_txt.nx nx_email_mx.nx nx_mdns.nx

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

67const NX_DNS_VERDICT_UNKNOWN: i64 = 0
68const NX_DNS_VERDICT_OK: i64 = 1
69const NX_DNS_VERDICT_BUF_TOO_SMALL: i64 = 2
70const NX_DNS_VERDICT_BAD_HEADER: i64 = 3
71const NX_DNS_VERDICT_BAD_LABEL: i64 = 4
72const NX_DNS_VERDICT_PTR_LOOP: i64 = 5
73const NX_DNS_VERDICT_PTR_OUT_OF_RANGE: i64 = 6
74const NX_DNS_VERDICT_TXID_MISMATCH: i64 = 7
75const NX_DNS_VERDICT_NOT_RESPONSE: i64 = 8
76const NX_DNS_VERDICT_TRUNCATED: i64 = 9
77const NX_DNS_VERDICT_RCODE_NONZERO: i64 = 10
78const NX_DNS_VERDICT_NO_A_RECORD: i64 = 11
79const NX_DNS_VERDICT_N: i64 = 12
82const NX_DNS_PORT: i64 = 53
83const NX_DNS_HEADER_LEN: i64 = 12
84const NX_DNS_TYPE_A: i64 = 1
85const NX_DNS_TYPE_NS: i64 = 2
86const NX_DNS_TYPE_CNAME: i64 = 5
87const NX_DNS_TYPE_SOA: i64 = 6
88const NX_DNS_TYPE_PTR: i64 = 12
89const NX_DNS_TYPE_MX: i64 = 15
90const NX_DNS_TYPE_TXT: i64 = 16
91const NX_DNS_TYPE_AAAA: i64 = 28
92const NX_DNS_CLASS_IN: i64 = 1
95const NX_DNS_FLAG_QR: i64 = 0x8000 // 1 = response
96const NX_DNS_FLAG_TC: i64 = 0x0200 // 1 = truncated
97const NX_DNS_FLAG_RD: i64 = 0x0100 // 1 = recursion desired
98const NX_DNS_FLAG_RA: i64 = 0x0080 // 1 = recursion available
99const NX_DNS_RCODE_MASK: i64 = 0x000f
106const NX_DNS_MAX_PTR_HOPS: i64 = 128
111const NX_DNS_MAX_RECORDS: i64 = 64

functions

115func nx_dns_put_u16_be(out: *u8, o: i64, v: i64) -> i64
121func nx_dns_get_u16_be(buf: *u8, o: i64) -> i64
127func nx_dns_get_u32_be(buf: *u8, o: i64) -> i64
144func nx_dns_encode_name(name: *u8, name_len: i64, out: *u8, out_cap: i64) -> i64
188func nx_dns_skip_name(buf: *u8, n: i64, start: i64) -> i64
255func nx_dns_build_query(
286func nx_dns_parse_response_a(
340func nx_dns_verdict_is_valid(v: i64) -> i64
called by 1: main