From 93d5dcdb70dfbb607efed36c6e9c9f1de4f6c2ff Mon Sep 17 00:00:00 2001 From: Fangliding Date: Fri, 9 Jan 2026 19:05:57 +0800 Subject: [PATCH] Check err in udp dns --- app/dns/nameserver_udp.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/dns/nameserver_udp.go b/app/dns/nameserver_udp.go index f263a0f8..55b825f7 100644 --- a/app/dns/nameserver_udp.go +++ b/app/dns/nameserver_udp.go @@ -160,7 +160,7 @@ func (s *ClassicNameServer) getCacheController() *CacheController { } // sendQuery implements CachedNameserver. -func (s *ClassicNameServer) sendQuery(ctx context.Context, _ chan<- error, fqdn string, option dns_feature.IPOption) { +func (s *ClassicNameServer) sendQuery(ctx context.Context, noResponseErrCh chan<- error, fqdn string, option dns_feature.IPOption) { errors.LogInfo(ctx, s.Name(), " querying DNS for: ", fqdn) reqs := buildReqMsgs(fqdn, option, s.newReqID, genEDNS0Options(s.clientIP, 0)) @@ -171,7 +171,14 @@ func (s *ClassicNameServer) sendQuery(ctx context.Context, _ chan<- error, fqdn ctx: ctx, } s.addPendingRequest(udpReq) - b, _ := dns.PackMessage(req.msg) + b, err := dns.PackMessage(req.msg) + if err != nil { + errors.LogErrorInner(ctx, err, "failed to pack dns query") + if noResponseErrCh != nil { + noResponseErrCh <- err + } + return + } copyDest := net.UDPDestination(s.address.Address, s.address.Port) b.UDP = ©Dest s.udpServer.Dispatch(toDnsContext(ctx, s.address.String()), *s.address, b)