mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 13:05:46 +00:00
wgengine/magicsock: check STUN regularly
This commit is contained in:
parent
7172f3dbf4
commit
4675c70464
@ -31,6 +31,7 @@
|
|||||||
"tailscale.com/stun"
|
"tailscale.com/stun"
|
||||||
"tailscale.com/stunner"
|
"tailscale.com/stunner"
|
||||||
"tailscale.com/types/key"
|
"tailscale.com/types/key"
|
||||||
|
"tailscale.com/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A Conn routes UDP packets and actively manages a list of its endpoints.
|
// A Conn routes UDP packets and actively manages a list of its endpoints.
|
||||||
@ -171,6 +172,16 @@ func (c *Conn) epUpdate(ctx context.Context) {
|
|||||||
var lastEndpoints []string
|
var lastEndpoints []string
|
||||||
var lastCancel func()
|
var lastCancel func()
|
||||||
var lastDone chan struct{}
|
var lastDone chan struct{}
|
||||||
|
|
||||||
|
var regularUpdate <-chan time.Time
|
||||||
|
if !version.IsMobile() {
|
||||||
|
// We assume that LinkChange notifications are plumbed through well
|
||||||
|
// on our mobile clients, so don't do the timer thing to save radio/battery/CPU/etc.
|
||||||
|
ticker := time.NewTicker(28 * time.Second) // just under 30s, a likely UDP NAT timeout
|
||||||
|
defer ticker.Stop()
|
||||||
|
regularUpdate = ticker.C
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
@ -179,6 +190,7 @@ func (c *Conn) epUpdate(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
case <-c.startEpUpdate:
|
case <-c.startEpUpdate:
|
||||||
|
case <-regularUpdate:
|
||||||
}
|
}
|
||||||
|
|
||||||
if lastCancel != nil {
|
if lastCancel != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user