浏览代码

fix(dns): avoid early return when dns query refused (#2878)

* avoid early return when dns query refused

* address reviews
dop-bot 1 年之前
父节点
当前提交
60f7a03e1b
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      app/dns/dns.go

+ 2 - 1
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
 		}
 	}