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

This commit is contained in:
gVisor bot 2023-09-02 20:56:42 +08:00
parent 6e0e53967a
commit df57d49d8d

View file

@ -18,6 +18,7 @@ import (
"github.com/Dreamacro/clash/log" "github.com/Dreamacro/clash/log"
D "github.com/miekg/dns" D "github.com/miekg/dns"
"github.com/samber/lo"
"golang.org/x/sync/singleflight" "golang.org/x/sync/singleflight"
) )
@ -332,7 +333,10 @@ func (r *Resolver) ipExchange(ctx context.Context, m *D.Msg) (msg *D.Msg, err er
res := <-msgCh res := <-msgCh
if res.Error == nil { if res.Error == nil {
if ips := msgToIP(res.Msg); len(ips) != 0 { if ips := msgToIP(res.Msg); len(ips) != 0 {
if !r.shouldIPFallback(ips[0]) { shouldNotFallback := lo.EveryBy(ips, func(ip netip.Addr) bool {
return !r.shouldIPFallback(ip)
})
if shouldNotFallback {
msg, err = res.Msg, res.Error // no need to wait for fallback result msg, err = res.Msg, res.Error // no need to wait for fallback result
return return
} }