Fix: should check all ips need to fallback (#2915)
This commit is contained in:
parent
02397868fc
commit
5f6de610e1
1 changed files with 6 additions and 2 deletions
|
@ -18,6 +18,7 @@ import (
|
|||
"github.com/Dreamacro/clash/log"
|
||||
|
||||
D "github.com/miekg/dns"
|
||||
"github.com/samber/lo"
|
||||
"golang.org/x/sync/singleflight"
|
||||
)
|
||||
|
||||
|
@ -200,7 +201,7 @@ func (r *Resolver) exchangeWithoutCache(ctx context.Context, m *D.Msg) (msg *D.M
|
|||
|
||||
isIPReq := isIPRequest(q)
|
||||
if isIPReq {
|
||||
cache=true
|
||||
cache = true
|
||||
return r.ipExchange(ctx, m)
|
||||
}
|
||||
|
||||
|
@ -332,7 +333,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 netip.Addr) bool {
|
||||
return !r.shouldIPFallback(ip)
|
||||
})
|
||||
if shouldNotFallback {
|
||||
msg, err = res.Msg, res.Error // no need to wait for fallback result
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue