wgengine, magicsock, tstun: don't regularly STUN when idle (mobile only for now)

If there's been 5 minutes of inactivity, stop doing STUN lookups. That
means NAT mappings will expire, but they can resume later when there's
activity again.

We'll do this for all platforms later.

Updates tailscale/corp#320

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2020-06-25 14:19:12 -07:00
committed by Brad Fitzpatrick
parent fe50cd0c48
commit 23e74a0f7a
5 changed files with 89 additions and 4 deletions

View File

@ -204,6 +204,7 @@ func newUserspaceEngineAdvanced(conf EngineConfig) (_ Engine, reterr error) {
Logf: logf,
Port: conf.ListenPort,
EndpointsFunc: endpointsFn,
IdleFunc: e.tundev.IdleDuration,
}
e.magicConn, err = magicsock.NewConn(magicsockOpts)
if err != nil {