fix(handler/dns): buffer pool leak, write deadline, async error logging, EDNS0 buffer

Fix bufpool leak when PackBuffer fails by extracting packResponse helper.
Add write deadline before conn.Write to prevent goroutine hangs on slow
clients. Log async exchange errors instead of silently discarding them.
Raise defaultBufferSize from 1024 to 4096 to match EDNS0 standard.
Deduplicate lookupHosts TypeA/TypeAAAA branches.
This commit is contained in:
ginuerzh
2026-05-26 21:22:19 +08:00
parent dd76e9f685
commit 79718ee19e
3 changed files with 162 additions and 60 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ const (
// 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
defaultBufferSize = 4096
)
// metadata holds parsed DNS handler configuration.