control-channel: Resolver filters the Name2IP and DNS groups separately

QA finding 1. `Resolver.addresses` applied one same-subnet check to the
union of the Name2IP mappings and the DNS results. `StartNewTcpClient`
checks each group on its own: the mapped group's failure is a `return`
that skips `Dns.GetHostEntry` entirely (SocketStuff.cs:934-937, 950), so
nothing is dialled for that name that round; the DNS group's failure
(:1037-1040) drops only the DNS addresses, because the mapped ones have
already been dialled (:941). Port that control flow, and document it in
the feature README's Assumptions and docs/protocol.md §10.3 note 6.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
lucioandClaude Opus 5 committed 2026-09-16 01:40:22 -07:00
1 parent 09ca9906e8
commit 43dc25ac71
3 files changed
+46 -20

No files matched your search

+12
View File
@@ -47,6 +47,18 @@ No packet is interpreted here.
Network.framework exposes them (`SocketStuff.cs:1283-1286`) — it
exposes none, so only `NoDelay` is set and the bounded outbox is what
limits queued bytes.
- **Name resolution filters each address group on its own**
(`SocketStuff.cs:928-944, 950, 989-1044`): `Resolver.addresses` runs the
same control flow `StartNewTcpClient` does, not a filter over the union.
The `Name2IP` mappings are checked against the same-subnet rule alone, and
when that check fails Windows returns from `StartNewTcpClient` **before**
`Dns.GetHostEntry` is called (`:934-937, 950`) — so the name is not dialled
at all that round and we return `[]`. The DNS group is filtered by the
reverse lookup and then gets its own same-subnet check (`:1037-1040`);
failing it drops the DNS addresses only, leaving the mapped ones, which
Windows has already handed to `StartNewTcpClientThread` by then. Reverse-
lookup validation never applies to a user-supplied mapping
(`docs/protocol.md` §10.3 note 6).
- **Keep one client per peer** (`SocketStuff.cs:1980-2004`): when a
second connection to the same peer name reaches `.connected`, the
later *client* connection is closed; inbound (server-side) connections
+11 -3
View File
@@ -658,13 +658,21 @@ sees them. One subsection per lane, appended, never rewritten.
connection, the counter in practice almost never reaches ten — it is a
same-connection guard, not a same-peer one.
6. **`Name2IP` is concatenated with a policy list, is used in addition to DNS,
and each group is filtered separately.** `Name2IpPolicyList + "\r\n" +
and each group is filtered separately — and a mapped group that fails the
subnet check aborts the whole round.** `Name2IpPolicyList + "\r\n" +
Name2IP` is split on CRLF and then on blanks (`:906-925`); the mapped
addresses get their own same-subnet check and are dialled **before**
`Dns.GetHostEntry` is called at all (`:930-941, 950`), while the DNS group
`Dns.GetHostEntry` is called at all (`:928-944, 950`), while the DNS group
gets the reverse-lookup filter (`:989-1032`) and then its own same-subnet
check (`:1035-1044`). Reverse-lookup validation therefore never applies to a
user-supplied mapping.
user-supplied mapping. The two checks fail differently: the mapped group's
failure is a `return` from `StartNewTcpClient` (`:934-937`) that skips DNS
resolution entirely, so **nothing** is dialled for that name that round; the
DNS group's failure is a `return` reached after the mapped addresses already
went to `StartNewTcpClientThread` (`:941, 1037-1040`), so it drops only the
DNS addresses. Filtering the union of the two groups instead would both
dial out-of-subnet DNS addresses whenever one mapped address matched, and
dial DNS addresses Windows never resolves.
7. **The socket options are per connection, set inside `MainTCPRoutine`.**
`SendBufferSize`/`ReceiveBufferSize = PACKAGE_SIZE * 10000` (320 000),
`NoDelay = true` and `SendTimeout = 500` are applied to the accepted or