mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-12 13:48:01 +00:00
ipn/ipnlocal: only call UpdateEndpoints when the endpoints change
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:

committed by
Josh Bleecher Snyder

parent
5b02ad16b9
commit
7421ba91ec
@@ -620,11 +620,16 @@ func (b *LocalBackend) setWgengineStatus(s *wgengine.Status, err error) {
|
||||
es := b.parseWgStatusLocked(s)
|
||||
cc := b.cc
|
||||
b.engineStatus = es
|
||||
b.endpoints = append([]tailcfg.Endpoint{}, s.LocalAddrs...)
|
||||
needUpdateEndpoints := !endpointsEqual(s.LocalAddrs, b.endpoints)
|
||||
if needUpdateEndpoints {
|
||||
b.endpoints = append([]tailcfg.Endpoint{}, s.LocalAddrs...)
|
||||
}
|
||||
b.mu.Unlock()
|
||||
|
||||
if cc != nil {
|
||||
cc.UpdateEndpoints(0, s.LocalAddrs)
|
||||
if needUpdateEndpoints {
|
||||
cc.UpdateEndpoints(0, s.LocalAddrs)
|
||||
}
|
||||
b.stateMachine()
|
||||
}
|
||||
|
||||
@@ -635,6 +640,18 @@ func (b *LocalBackend) setWgengineStatus(s *wgengine.Status, err error) {
|
||||
b.send(ipn.Notify{Engine: &es})
|
||||
}
|
||||
|
||||
func endpointsEqual(x, y []tailcfg.Endpoint) bool {
|
||||
if len(x) != len(y) {
|
||||
return false
|
||||
}
|
||||
for i := range x {
|
||||
if x[i] != y[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *LocalBackend) SetNotifyCallback(notify func(ipn.Notify)) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
Reference in New Issue
Block a user