A zone transfer over DNS-over-TLS no longer loses its last message on Windows when the client sent one more query #370

Merged
claude merged 2 commits from feature/340-dot-transfer-close into develop 2026-11-12 00:48:33 -05:00
Owner

A zone transfer over DNS-over-TLS no longer loses its last message on Windows when the client has already sent another query.

  • Cause: after a transfer, DnsOverTlsListener closed the socket through SslStream and NetworkStream while the client's next frame sat unread. That close sends a reset, and a Windows client then discards the reply it had already received. #12 fixed the same thing for plain TCP and DNSCrypt TCP.
  • Fix: when the session ends after a drained close (FramedDnsStreamSession.ClosedAfterDrain), the listener sends the TLS close alert (RFC 8446 §6.1). It then closes the socket with LingeringSocketClose. Only after that does it dispose the streams.
    • Each of the first two steps is limited to 2 s and to the stopping token.
    • Aborted, timed-out and idle connections close at once, as before.
    • The connection-limiter slot is released in a finally.
  • Test: DnsOverTlsZoneTransferCloseTests (port 0 plus BoundPort, 20 rounds over a TLS client).
  • Not affected: DoH has no transfer path. DoQ uses one stream per query.

Verified:

  • On Lofnheim the test is red without the fix (Assert.NotNull on the last message) and green with it. Both the coder and the verifier showed this.
  • The DoT test project passed 48/48 on Windows and on Linux: 10 runs by the coder and 5 by the verifier on each.
  • The build has 0 warnings and csharpier is clean.
  • The verifier checked both RFC references against the RFC text.
  • A slot can be held up to about 4 s after a completed transfer; plain TCP holds it for 2 s.

Closes #340

🤖 Generated with Claude Code

https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK

A zone transfer over DNS-over-TLS no longer loses its last message on Windows when the client has already sent another query. - **Cause:** after a transfer, `DnsOverTlsListener` closed the socket through `SslStream` and `NetworkStream` while the client's next frame sat unread. That close sends a reset, and a Windows client then discards the reply it had already received. #12 fixed the same thing for plain TCP and DNSCrypt TCP. - **Fix:** when the session ends after a drained close (`FramedDnsStreamSession.ClosedAfterDrain`), the listener sends the TLS close alert (RFC 8446 §6.1). It then closes the socket with `LingeringSocketClose`. Only after that does it dispose the streams. - Each of the first two steps is limited to 2 s and to the stopping token. - Aborted, timed-out and idle connections close at once, as before. - The connection-limiter slot is released in a `finally`. - **Test:** `DnsOverTlsZoneTransferCloseTests` (port 0 plus `BoundPort`, 20 rounds over a TLS client). - **Not affected:** DoH has no transfer path. DoQ uses one stream per query. **Verified:** - On Lofnheim the test is red without the fix (`Assert.NotNull` on the last message) and green with it. Both the coder and the verifier showed this. - The DoT test project passed 48/48 on Windows and on Linux: 10 runs by the coder and 5 by the verifier on each. - The build has 0 warnings and csharpier is clean. - The verifier checked both RFC references against the RFC text. - A slot can be held up to about 4 s after a completed transfer; plain TCP holds it for 2 s. Closes #340 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Closes #340

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
The DNS-over-TLS connection summary and the transfer-close test now describe the lingering close and the test's settle delay
Some checks failed
Build / Pack and Push NuGet Packages (dhcp) (push) Has been skipped
Build / Pack and Push NuGet Packages (dns-core) (push) Has been skipped
Build / Stage Draft Release (pull_request) Successful in -2m34s
Build / Pack and Push NuGet Packages (dns-server) (push) Has been skipped
Build / Pack and Push NuGet Packages (common) (pull_request) Successful in -2m20s
Build / Pack and Push NuGet Packages (dhcp) (pull_request) Successful in -2m5s
Build / Pack and Push NuGet Packages (dns-core) (pull_request) Successful in -2m2s
Build / Pack and Push NuGet Packages (dns-server) (pull_request) Successful in -1m50s
Build / Build Binary (linux-arm64) (push) Has been skipped
Build / Build Binary (macos-amd64) (push) Has been skipped
Build / Build Binary (windows-amd64) (push) Has been skipped
Build / Smoke Test the Windows Binary (push) Has been skipped
Build / Build Binary (linux-amd64) (push) Has been skipped
Build / Build Binary (macos-arm64) (push) Has been skipped
Build / Build Binary (linux-amd64) (pull_request) Successful in -37s
Build / Build Binary (linux-arm64) (pull_request) Successful in -37s
Build / Build Binary (macos-amd64) (pull_request) Successful in -1m2s
Build / Build Binary (macos-arm64) (pull_request) Successful in -35s
Build / Build Binary (windows-amd64) (pull_request) Successful in -34s
Build / Smoke Test the Windows Binary (pull_request) Successful in 15s
Build / Build Arch Linux Packages (push) Has been skipped
Build / Build and Test Deb and RPM Packages (push) Has been skipped
Build / Build and Push Image (push) Has been skipped
Build / Build Arch Linux Packages (pull_request) Successful in -2m21s
Build / Build and Push Image (pull_request) Successful in -2m29s
Build / Build and Test Deb and RPM Packages (pull_request) Successful in -13s
Build / Publish Release (push) Has been skipped
Build / Pipeline (push) Failing after 0s
Build / Publish Release (pull_request) Successful in -2m26s
Build / Pipeline (pull_request) Successful in 0s
bf9ae4a2d9
Refs #340

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
claude merged commit 014094cc32 into develop 2026-11-12 00:48:33 -05:00
claude deleted branch feature/340-dot-transfer-close 2026-11-12 00:48:34 -05:00
Sign in to join this conversation.
No reviewers
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.

Dependencies

No dependencies set

Reference
lantea-one/ninlil!370
No description provided.