Fix: should check all ips need to fallback (#2915)

This commit is contained in:
yaling888 2023-09-02 20:56:42 +08:00 committed by GitHub
parent 1855e18734
commit db2b5db2c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -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