From 60f7a03e1b5e952f9d15f1a136bfabd24e80d9bd Mon Sep 17 00:00:00 2001 From: dop-bot <95738113+dop-bot@users.noreply.github.com> Date: Tue, 2 Jan 2024 12:03:36 +0800 Subject: [PATCH] fix(dns): avoid early return when dns query refused (#2878) * avoid early return when dns query refused * address reviews --- app/dns/dns.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/dns/dns.go b/app/dns/dns.go index 6efcb825..3b173677 100644 --- a/app/dns/dns.go +++ b/app/dns/dns.go @@ -215,7 +215,8 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, error) { newError("failed to lookup ip for domain ", domain, " at server ", client.Name()).Base(err).WriteToLog() errs = append(errs, err) } - if err != context.Canceled && err != context.DeadlineExceeded && err != errExpectedIPNonMatch && err != dns.ErrEmptyResponse { + // 5 for RcodeRefused in miekg/dns, hardcode to reduce binary size + if err != context.Canceled && err != context.DeadlineExceeded && err != errExpectedIPNonMatch && err != dns.ErrEmptyResponse && dns.RCodeFromError(err) != 5 { return nil, err } }