Skip to content

fix(dnsserver): abort dropped DoH responses after cancellation - #431

Merged
TMHSDigital merged 1 commit into
TMHSDigital:mainfrom
laozhej:fix/392-doh-drop-cancellation
Nov 17, 2026
Merged

TMHSDigital merged 1 commit into
TMHSDigital:mainfrom
laozhej:fix/392-doh-drop-cancellation

Conversation

@laozhej

@laozhej laozhej commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Description

A dropped DoH request now aborts without sending HTTP headers after its server context ends. Returning normally allowed net/http to send an implicit empty 200 if the server observed cancellation before the client. The handler uses http.ErrAbortHandler, which aborts the response without logging a panic stack.

The existing dropped-query test waits until the query reaches the handler, checks that it stays unanswered, and then explicitly cancels the client. Its 10-second timeout is a failure bound instead of the former 200 ms delivery deadline. A separate test cancels only the server context while keeping the client live, reproducing the empty-200 failure deterministically.

Related Issue

Fixes #392.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvements
  • Test updates

Checklist

  • I have read the CONTRIBUTING document
  • My code follows the code style of this project
  • I have added/updated appropriate comments to the code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable; internal fixture behavior only)

Ethical Considerations

  • This change maintains or improves the security controls in the tool
  • This change follows the educational/legitimate security testing focus of the project
  • I have considered potential misuse cases and taken appropriate steps to prevent them

Additional Information

Validated on macOS arm64 with Go 1.26.11 and golangci-lint 2.15.0:

  • Before the fix, TestDoHHandlerCanceledServerContext fails with dropped request answered with status 200 after server cancellation; afterward it gets EOF without an HTTP response.
  • go test -count=1000 -run TestDoHHandler ./internal/dnsserver/ passes, including both client cancellation and server cancellation coverage (29.132s).
  • go test -race -shuffle=on ./... passes all 22 packages with tests; it ran concurrently with the repeated DoH test.
  • make lint reports 0 issues; make build, gofmt, and git diff --check pass, using the installed Command Line Tools make.

Tests use local DNS/HTTPS fixtures only. Prepared with OpenAI Codex assistance.

@TMHSDigital
TMHSDigital merged commit acfa74d into TMHSDigital:main Nov 17, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TestDoHHandler/dropped flakes: dropped DoH query answered 200 or not counted

2 participants