nx_dns_authoritative.nx
buildroot/runtime/nx_dns_authoritative.nx
about
nx_dns_authoritative.nx -- UDP/53 authoritative DNS serve.
Composes the shipped DNS substrate (nx_dns.nx endian + label
encode/decode + parse) + UDP socket syscalls to serve A records
from a caller-provided zone table.
Per cardinal feedback-no-third-party-trust-native-or-nothing:
substrate's own authoritative DNS. No bind, no powerdns, no
nsd, no Cloudflare API.
Per cardinal user-owns-every-bit:
- Caller provides the zone-table buffer + the listen address.
- Substrate doesn't auto-bind to 0.0.0.0:53. Default helper
uses 127.0.0.1; public binding is an explicit caller choice.
- No upstream resolution. This is AUTHORITATIVE only (RFC 1035
ยง6). Out-of-zone queries get REFUSED, not forwarded.
What this primitive does:
1. Parse incoming DNS query packet
2. Extract QNAME + QTYPE
3. Look up QNAME in caller's zone table
4. Build response: header + question echo + answer or NXDOMAIN
What this primitive does NOT do (queued):
- DNSSEC signing (RFC 4035): nx_dns_dnssec_sign.nx queued
- TCP DNS (RFC 7766): use UDP-truncated TC bit to force retry
- Zone transfer (AXFR/IXFR): only single-server today
- Recursive resolution: out-of-zone -> REFUSED
- EDNS(0) OPT pseudo-record: ignored on input, omitted on output
Sealed enums:
NxDnsAuthVerdict (7 states):
OK / SOCKET_ERR / BIND_ERR / RECV_ERR / PARSE_ERR /
SEND_ERR / BAD_ARG
NxDnsResponseClass (4 states for canonical response codes):
NOERROR (0) -- answer matched zone
NXDOMAIN (3) -- name not in zone
REFUSED (5) -- name not in this server's zone (out-of-scope)
dependencies 2 imports · 3 importers
imports: nx_syscalls_x86_64.nxnx_dns.nx
imported by: nx_dns_adversarial_test.nxnx_dns_authoritative_test.nxnx_dns_server_daemon.nx
structs
| 98 | struct NxDnsZone |
consts
| 59 | const NXDA_OK: i64 = 0 |
| 60 | const NXDA_SOCKET_ERR: i64 = 1 |
| 61 | const NXDA_BIND_ERR: i64 = 2 |
| 62 | const NXDA_RECV_ERR: i64 = 3 |
| 63 | const NXDA_PARSE_ERR: i64 = 4 |
| 64 | const NXDA_SEND_ERR: i64 = 5 |
| 65 | const NXDA_BAD_ARG: i64 = 6 |
| 66 | const NXDA_VERDICT_N: i64 = 7 |
| 87 | const NXDA_RCODE_NOERROR: i64 = 0 |
| 88 | const NXDA_RCODE_SERVFAIL: i64 = 2 |
| 89 | const NXDA_RCODE_NXDOMAIN: i64 = 3 |
| 90 | const NXDA_RCODE_REFUSED: i64 = 5 |
| 107 | const NX_DNS_ZONE_BYTES: i64 = 48 |
functions
| 68 | func nxda_verdict_is_valid(v: i64) -> i64 called by 1: main |
| 74 | func nxda_verdict_name(v: i64) -> *u8 called by 1: main |
| 109 | func nx_dns_zone_init(z: *NxDnsZone, cap: i64, |
| 126 | func nx_dns_zone_add_a(z: *NxDnsZone, |
| 167 | func nx_dns_decode_name_ascii(buf: *u8, n: i64, start: i64, |
| 209 | func nx_dns_zone_lookup_a(z: *NxDnsZone, |
| 243 | func nx_dns_build_response( |
| 339 | func nx_dns_serve_query(z: *NxDnsZone, called by 2: mainmain calls 4: nx_dns_get_u16_benx_dns_build_responsenx_dns_decode_name_asciinx_dns_zone_lookup_a |