From c4994d642963c825b1070dc19d63511bbe536fc8 Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Tue, 25 Feb 2020 21:51:48 +0800 Subject: [PATCH] Fix: dns not cache RcodeServerFailure --- dns/resolver.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dns/resolver.go b/dns/resolver.go index fefdafdc..b6dfc733 100644 --- a/dns/resolver.go +++ b/dns/resolver.go @@ -168,7 +168,13 @@ func (r *Resolver) batchExchange(clients []dnsClient, m *D.Msg) (msg *D.Msg, err for _, client := range clients { r := client fast.Go(func() (interface{}, error) { - return r.ExchangeContext(ctx, m) + m, err := r.ExchangeContext(ctx, m) + if err != nil { + return nil, err + } else if m.Rcode == D.RcodeServerFailure { + return nil, errors.New("server failure") + } + return m, nil }) }