mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-05-12 04:58:02 +08:00
chore: stop retry when couldn't find ip
This commit is contained in:
parent
33bc7914e9
commit
2e12ceeaed
@ -289,8 +289,6 @@ func listenPacket(ctx context.Context, proxyAdapter C.ProxyAdapter, proxyName st
|
||||
return proxyAdapter.ListenPacketContext(ctx, metadata, opts...)
|
||||
}
|
||||
|
||||
var errIPNotFound = errors.New("couldn't find ip")
|
||||
|
||||
func batchExchange(ctx context.Context, clients []dnsClient, m *D.Msg) (msg *D.Msg, cache bool, err error) {
|
||||
cache = true
|
||||
fast, ctx := picker.WithTimeout[*D.Msg](ctx, resolver.DefaultDNSTimeout)
|
||||
@ -320,12 +318,12 @@ func batchExchange(ctx context.Context, clients []dnsClient, m *D.Msg) (msg *D.M
|
||||
case D.TypeAAAA:
|
||||
if len(ips) == 0 {
|
||||
noIpMsg = m
|
||||
return nil, errIPNotFound
|
||||
return nil, resolver.ErrIPNotFound
|
||||
}
|
||||
case D.TypeA:
|
||||
if len(ips) == 0 {
|
||||
noIpMsg = m
|
||||
return nil, errIPNotFound
|
||||
return nil, resolver.ErrIPNotFound
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package tunnel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/netip"
|
||||
@ -684,6 +685,19 @@ func getRules(metadata *C.Metadata) []C.Rule {
|
||||
}
|
||||
}
|
||||
|
||||
func shouldStopRetry(err error) bool {
|
||||
if errors.Is(err, resolver.ErrIPNotFound) {
|
||||
return true
|
||||
}
|
||||
if errors.Is(err, resolver.ErrIPVersion) {
|
||||
return true
|
||||
}
|
||||
if errors.Is(err, resolver.ErrIPv6Disabled) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func retry[T any](ctx context.Context, ft func(context.Context) (T, error), fe func(err error)) (t T, err error) {
|
||||
b := &backoff.Backoff{
|
||||
Min: 10 * time.Millisecond,
|
||||
@ -697,6 +711,9 @@ func retry[T any](ctx context.Context, ft func(context.Context) (T, error), fe f
|
||||
if fe != nil {
|
||||
fe(err)
|
||||
}
|
||||
if shouldStopRetry(err) {
|
||||
return
|
||||
}
|
||||
select {
|
||||
case <-time.After(b.Duration()):
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user