Queries for names in the hosts files get A, AAAA and PTR answers from them, and bare names are answered in their place in the lookup order #175

Open
opened 2026-10-31 12:42:20 -04:00 by claude · 0 comments
Owner
  • Draft: PN-31
  • Priority: medium
  • Agent: protocol-coder
  • Depends on: #174, #136
  • Decisions: Q-PN-11, R2-BARE

Why

See #173.

What changes

  • New HostsFileQueryResolver : IDnsQueryResolver (src/dotnet/src/Ninlil.Dns.Server.Core/Resolution/IDnsQueryResolver.cs:16-33) in Ninlil.Dns.Server.HostsFiles, answering multi-label names and PTR as #173 defines. Reply shape like a rewrite answer (DnsRewriteEngine.BuildResponse, src/dotnet/src/Ninlil.Dns.Server.Rewrites/DnsRewriteEngine.cs:257-308), with TimeToLiveSeconds from the options; NODATA replies carry no SOA because no zone exists (RFC 2308 §2.2 allows it; the negative answer is then not cached). A single-label query name returns NotHandled.
  • New HostsFileHostNameSource : ILocalHostNameSource (#136) with Order = LocalHostNameSourceOrder.HostsFiles, answering a bare name from the table (A/AAAA; NODATA when the name has no address of the asked family). It answers after DHCP-registered names (#137) and before the local domain (#138).
  • Registration order: Program.cs registers the resolver after AddNinlilDnsServerAuthoritative and before forwarding; update the order comment at Program.cs:496-502 and the resolver list in IDnsQueryResolver.cs:7-9. The source is registered as an ILocalHostNameSource.
  • README.md "Hosts files" section (see #173 acceptance).

Acceptance

  • This test fails first: TryResolve_ForANameInAHostsFile_ReturnsItsAddress in src/dotnet/tests/Ninlil.Dns.Server.HostsFiles.Tests.
  • Tests: AAAA for an IPv4-only name returns NODATA; MX for a hosts name returns NotHandled; PTR returns the first name; PTR with ExpandDomain returns the expanded name; a name in no file returns NotHandled; a single-label nas returns NotHandled from the resolver.
  • Tests with the real LocalNetworkGuard (#136): nas in a hosts file is answered by the source; with a fake DHCP source (order 100) also holding nas at another address, the DHCP address wins; with a fake local-domain source (order 300) holding nas, the hosts address wins.
  • A pipeline test in src/dotnet/tests/Ninlil.Web.Tests (shared host, temp file set through the options) shows a block-list entry still blocks a hosts name.
  • README.md updated.
  • Gate: dotnet test src/dotnet/tests/Ninlil.Dns.Server.HostsFiles.Tests, dotnet test src/dotnet/tests/Ninlil.Web.Tests.

Source

audit-feature-parity.md §2A #15; RFC 1035 §3.5, RFC 3596 §2.5, RFC 2308 §2.2; DEDUPE.md P6.
Owner decision 2026-10-31: Q-PN-11; round 2 R2-BARE (hosts files are the second bare-name source).

- **Draft:** PN-31 - **Priority:** medium - **Agent:** protocol-coder - **Depends on:** #174, #136 - **Decisions:** Q-PN-11, R2-BARE ### Why See #173. ### What changes - New `HostsFileQueryResolver : IDnsQueryResolver` (`src/dotnet/src/Ninlil.Dns.Server.Core/Resolution/IDnsQueryResolver.cs:16-33`) in `Ninlil.Dns.Server.HostsFiles`, answering multi-label names and PTR as #173 defines. Reply shape like a rewrite answer (`DnsRewriteEngine.BuildResponse`, `src/dotnet/src/Ninlil.Dns.Server.Rewrites/DnsRewriteEngine.cs:257-308`), with `TimeToLiveSeconds` from the options; NODATA replies carry no SOA because no zone exists (RFC 2308 §2.2 allows it; the negative answer is then not cached). A single-label query name returns NotHandled. - New `HostsFileHostNameSource : ILocalHostNameSource` (#136) with `Order = LocalHostNameSourceOrder.HostsFiles`, answering a bare name from the table (A/AAAA; NODATA when the name has no address of the asked family). It answers after DHCP-registered names (#137) and before the local domain (#138). - Registration order: `Program.cs` registers the resolver after `AddNinlilDnsServerAuthoritative` and before forwarding; update the order comment at `Program.cs:496-502` and the resolver list in `IDnsQueryResolver.cs:7-9`. The source is registered as an `ILocalHostNameSource`. - README.md "Hosts files" section (see #173 acceptance). ### Acceptance - [ ] This test fails first: `TryResolve_ForANameInAHostsFile_ReturnsItsAddress` in `src/dotnet/tests/Ninlil.Dns.Server.HostsFiles.Tests`. - [ ] Tests: AAAA for an IPv4-only name returns NODATA; MX for a hosts name returns NotHandled; PTR returns the first name; PTR with `ExpandDomain` returns the expanded name; a name in no file returns NotHandled; a single-label `nas` returns NotHandled from the resolver. - [ ] Tests with the real `LocalNetworkGuard` (#136): `nas` in a hosts file is answered by the source; with a fake DHCP source (order 100) also holding `nas` at another address, the DHCP address wins; with a fake local-domain source (order 300) holding `nas`, the hosts address wins. - [ ] A pipeline test in `src/dotnet/tests/Ninlil.Web.Tests` (shared host, temp file set through the options) shows a block-list entry still blocks a hosts name. - [ ] README.md updated. - [ ] Gate: `dotnet test src/dotnet/tests/Ninlil.Dns.Server.HostsFiles.Tests`, `dotnet test src/dotnet/tests/Ninlil.Web.Tests`. ### Source `audit-feature-parity.md` §2A #15; RFC 1035 §3.5, RFC 3596 §2.5, RFC 2308 §2.2; DEDUPE.md P6. Owner decision 2026-10-31: Q-PN-11; round 2 R2-BARE (hosts files are the second bare-name source).
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
lantea-one/ninlil#175
No description provided.