Skip to content

Commit 7850079

Browse files
committed
ipn/auto: delay for 2s if rpn unhealthy
give it a few seconds to recover (typically, it may take around 5s for wg handshakes to complete, but we do not have the luxury to wait that longer given DNS53 timeouts may be shorter)
1 parent 3ce66de commit 7850079

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

intra/ipn/auto.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ import (
2020
)
2121

2222
const (
23-
ttl30s = 30 * time.Second
24-
shortdelay = 100 * time.Millisecond
23+
ttl30s = 30 * time.Second
24+
shortdelay = 100 * time.Millisecond
25+
delayForUnhealthyProxies = 2 * time.Second
2526
)
2627

2728
// exit is a proxy that always dials out to the internet.
@@ -557,9 +558,10 @@ func (*auto) dialAlways(p Proxy, network, local, remote string) (net.Conn, error
557558
return p.Dialer().Dial(network, remote)
558559
}
559560

560-
func (*auto) dialIfHealthy(p Proxy, network, local, remote string) (net.Conn, error) {
561+
func (a *auto) dialIfHealthy(p Proxy, network, local, remote string) (net.Conn, error) {
561562
if err := healthy(p); err != nil {
562-
return nil, fmt.Errorf("auto dial; %s %s not ok; %v: %s", p.ID(), network, err, remote)
563+
log.E("auto dial; %s %s not ok; %v: %s", p.ID(), network, err, remote)
564+
time.Sleep(delayForUnhealthyProxies)
563565
}
564566
if len(local) > 0 {
565567
return p.Dialer().DialBind(network, local, remote)

0 commit comments

Comments
 (0)