fix(handler/dns): apply readTimeout, fix async context leak, add 40 tests

- Apply parsed readTimeout as connection read deadline (was dead code)
- Use context.WithoutCancel for async cache refresh goroutine
- Add doc comments to all exported symbols
- Add 40 tests covering metadata parsing, init, rate limiting,
  exchanger selection, host lookup, cache, bypass, async refresh,
  and concurrent request handling
This commit is contained in:
ginuerzh
2026-05-26 20:55:55 +08:00
parent b3424b769e
commit dd76e9f685
3 changed files with 1038 additions and 5 deletions
+4 -1
View File
@@ -10,10 +10,13 @@ import (
)
const (
defaultTimeout = 5 * time.Second
// defaultTimeout is the fallback timeout for DNS exchanges.
defaultTimeout = 5 * time.Second
// defaultBufferSize is the fallback buffer size for DNS message I/O.
defaultBufferSize = 1024
)
// metadata holds parsed DNS handler configuration.
type metadata struct {
readTimeout time.Duration
ttl time.Duration