mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-12 00:52:00 +00:00
control/controlclient, types/netmap: start plumbing delta netmap updates
Currently only the top four most popular changes: endpoints, DERP home, online, and LastSeen. Updates #1909 Change-Id: I03152da176b2b95232b56acabfb55dcdfaa16b79 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
c0ade132e6
commit
3af051ea27
@@ -8,6 +8,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/netip"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -15,6 +16,7 @@ import (
|
||||
"tailscale.com/tka"
|
||||
"tailscale.com/types/key"
|
||||
"tailscale.com/types/views"
|
||||
"tailscale.com/util/cmpx"
|
||||
"tailscale.com/wgengine/filter"
|
||||
)
|
||||
|
||||
@@ -124,6 +126,23 @@ func (nm *NetworkMap) PeerByTailscaleIP(ip netip.Addr) (peer tailcfg.NodeView, o
|
||||
return tailcfg.NodeView{}, false
|
||||
}
|
||||
|
||||
// PeerIndexByNodeID returns the index of the peer with the given nodeID
|
||||
// in nm.Peers, or -1 if nm is nil or not found.
|
||||
//
|
||||
// It assumes nm.Peers is sorted by Node.ID.
|
||||
func (nm *NetworkMap) PeerIndexByNodeID(nodeID tailcfg.NodeID) int {
|
||||
if nm == nil {
|
||||
return -1
|
||||
}
|
||||
idx, ok := sort.Find(len(nm.Peers), func(i int) int {
|
||||
return cmpx.Compare(nodeID, nm.Peers[i].ID())
|
||||
})
|
||||
if !ok {
|
||||
return -1
|
||||
}
|
||||
return idx
|
||||
}
|
||||
|
||||
// MagicDNSSuffix returns the domain's MagicDNS suffix (even if MagicDNS isn't
|
||||
// necessarily in use) of the provided Node.Name value.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user