From db2b5db2c6e22e3e77bac43e2d4e4bd88b085017 Mon Sep 17 00:00:00 2001 From: yaling888 <73897884+yaling888@users.noreply.github.com> Date: Sat, 2 Sep 2023 20:56:42 +0800 Subject: [PATCH] Fix: should check all ips need to fallback (#2915) --- dns/resolver.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dns/resolver.go b/dns/resolver.go index 6342e0a..097be18 100644 --- a/dns/resolver.go +++ b/dns/resolver.go @@ -265,7 +265,10 @@ func (r *Resolver) ipExchange(ctx context.Context, m *D.Msg) (msg *D.Msg, err er res := <-msgCh if res.Error == nil { if ips := msgToIP(res.Msg); len(ips) != 0 { - if !r.shouldIPFallback(ips[0]) { + shouldNotFallback := lo.EveryBy(ips, func(ip net.IP) bool { + return !r.shouldIPFallback(ip) + }) + if shouldNotFallback { msg = res.Msg // no need to wait for fallback result err = res.Error return msg, err