tailcfg, net/portmapper, wgengine/magicsock: add NetInfo.HavePortMap

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2021-03-09 15:09:10 -08:00
committed by Brad Fitzpatrick
parent 79d8288f0a
commit ef7bac2895
5 changed files with 43 additions and 2 deletions

View File

@@ -63,6 +63,13 @@ type Client struct {
pmpMapping *pmpMapping // non-nil if we have a PMP mapping
}
// HaveMapping reports whether we have a current valid mapping.
func (c *Client) HaveMapping() bool {
c.mu.Lock()
defer c.mu.Unlock()
return c.pmpMapping != nil && c.pmpMapping.useUntil.After(time.Now())
}
// pmpMapping is an already-created PMP mapping.
//
// All fields are immutable once created.