|
|
@ -111,15 +111,16 @@ type userspaceEngine struct {
|
|
|
|
sentActivityAt map[netaddr.IP]*int64 // value is atomic int64 of unixtime
|
|
|
|
sentActivityAt map[netaddr.IP]*int64 // value is atomic int64 of unixtime
|
|
|
|
destIPActivityFuncs map[netaddr.IP]func()
|
|
|
|
destIPActivityFuncs map[netaddr.IP]func()
|
|
|
|
|
|
|
|
|
|
|
|
mu sync.Mutex // guards following; see lock order comment below
|
|
|
|
mu sync.Mutex // guards following; see lock order comment below
|
|
|
|
closing bool // Close was called (even if we're still closing)
|
|
|
|
closing bool // Close was called (even if we're still closing)
|
|
|
|
statusCallback StatusCallback
|
|
|
|
statusCallback StatusCallback
|
|
|
|
linkChangeCallback func(major bool, newState *interfaces.State)
|
|
|
|
linkChangeCallback func(major bool, newState *interfaces.State)
|
|
|
|
peerSequence []wgkey.Key
|
|
|
|
peerSequence []wgkey.Key
|
|
|
|
endpoints []string
|
|
|
|
endpoints []string
|
|
|
|
pingers map[wgkey.Key]*pinger // legacy pingers for pre-discovery peers
|
|
|
|
pingers map[wgkey.Key]*pinger // legacy pingers for pre-discovery peers
|
|
|
|
linkState *interfaces.State
|
|
|
|
linkState *interfaces.State
|
|
|
|
pendOpen map[flowtrack.Tuple]*pendingOpenFlow // see pendopen.go
|
|
|
|
pendOpen map[flowtrack.Tuple]*pendingOpenFlow // see pendopen.go
|
|
|
|
|
|
|
|
networkMapCallbacks map[*someHandle]NetworkMapCallback
|
|
|
|
|
|
|
|
|
|
|
|
// Lock ordering: magicsock.Conn.mu, wgLock, then mu.
|
|
|
|
// Lock ordering: magicsock.Conn.mu, wgLock, then mu.
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1290,6 +1291,21 @@ func (e *userspaceEngine) SetLinkChangeCallback(cb func(major bool, newState *in
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (e *userspaceEngine) AddNetworkMapCallback(cb NetworkMapCallback) func() {
|
|
|
|
|
|
|
|
e.mu.Lock()
|
|
|
|
|
|
|
|
defer e.mu.Unlock()
|
|
|
|
|
|
|
|
if e.networkMapCallbacks == nil {
|
|
|
|
|
|
|
|
e.networkMapCallbacks = make(map[*someHandle]NetworkMapCallback)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
h := new(someHandle)
|
|
|
|
|
|
|
|
e.networkMapCallbacks[h] = cb
|
|
|
|
|
|
|
|
return func() {
|
|
|
|
|
|
|
|
e.mu.Lock()
|
|
|
|
|
|
|
|
defer e.mu.Unlock()
|
|
|
|
|
|
|
|
delete(e.networkMapCallbacks, h)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func getLinkState() (*interfaces.State, error) {
|
|
|
|
func getLinkState() (*interfaces.State, error) {
|
|
|
|
s, err := interfaces.GetState()
|
|
|
|
s, err := interfaces.GetState()
|
|
|
|
if s != nil {
|
|
|
|
if s != nil {
|
|
|
@ -1308,6 +1324,15 @@ func (e *userspaceEngine) SetDERPMap(dm *tailcfg.DERPMap) {
|
|
|
|
|
|
|
|
|
|
|
|
func (e *userspaceEngine) SetNetworkMap(nm *controlclient.NetworkMap) {
|
|
|
|
func (e *userspaceEngine) SetNetworkMap(nm *controlclient.NetworkMap) {
|
|
|
|
e.magicConn.SetNetworkMap(nm)
|
|
|
|
e.magicConn.SetNetworkMap(nm)
|
|
|
|
|
|
|
|
e.mu.Lock()
|
|
|
|
|
|
|
|
callbacks := make([]NetworkMapCallback, 0, 4)
|
|
|
|
|
|
|
|
for _, fn := range e.networkMapCallbacks {
|
|
|
|
|
|
|
|
callbacks = append(callbacks, fn)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
e.mu.Unlock()
|
|
|
|
|
|
|
|
for _, fn := range callbacks {
|
|
|
|
|
|
|
|
fn(nm)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (e *userspaceEngine) DiscoPublicKey() tailcfg.DiscoKey {
|
|
|
|
func (e *userspaceEngine) DiscoPublicKey() tailcfg.DiscoKey {
|
|
|
|