mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-12-22 23:57:26 +08:00
chore: periodically try fallback
This commit is contained in:
parent
72ab200faf
commit
7468d08e4d
@ -195,8 +195,8 @@ func dualStackDialContext(
|
|||||||
ipv4DialFn func(ctx context.Context) (net.Conn, error),
|
ipv4DialFn func(ctx context.Context) (net.Conn, error),
|
||||||
ipv6DialFn func(ctx context.Context) (net.Conn, error),
|
ipv6DialFn func(ctx context.Context) (net.Conn, error),
|
||||||
preferIPv4 bool) (net.Conn, error) {
|
preferIPv4 bool) (net.Conn, error) {
|
||||||
fallbackTimer := time.NewTimer(fallbackTimeout)
|
fallbackTicker := time.NewTicker(fallbackTimeout)
|
||||||
defer fallbackTimer.Stop()
|
defer fallbackTicker.Stop()
|
||||||
results := make(chan dialResult)
|
results := make(chan dialResult)
|
||||||
returned := make(chan struct{})
|
returned := make(chan struct{})
|
||||||
defer close(returned)
|
defer close(returned)
|
||||||
@ -224,7 +224,7 @@ func dualStackDialContext(
|
|||||||
return fallback.Conn, nil
|
return fallback.Conn, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("dual stack connect failed: %w", err)
|
return nil, fmt.Errorf("dual stack connect failed: %w", err)
|
||||||
case <-fallbackTimer.C:
|
case <-fallbackTicker.C:
|
||||||
if fallback.error == nil && fallback.Conn != nil {
|
if fallback.error == nil && fallback.Conn != nil {
|
||||||
return fallback.Conn, nil
|
return fallback.Conn, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user