mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 21:27:31 +00:00
types/netmap: start phasing out Addresses, add GetAddresses method
NetworkMap.Addresses is redundant with the SelfNode.Addresses. This works towards a TODO to delete NetworkMap.Addresses and replace it with a method. This is similar to #9389. Updates #cleanup Change-Id: Id000509ca5d16bb636401763d41bdb5f38513ba0 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
fb5ceb03e3
commit
926c990a09
@@ -35,7 +35,8 @@ type NetworkMap struct {
|
||||
|
||||
// Addresses is SelfNode.Addresses. (IP addresses of this Node directly)
|
||||
//
|
||||
// TODO(bradfitz): remove this field and make this a method.
|
||||
// Deprecated: use GetAddresses instead. As of 2023-09-17, this field
|
||||
// is being phased out.
|
||||
Addresses []netip.Prefix
|
||||
|
||||
// MachineStatus is either tailcfg.MachineAuthorized or tailcfg.MachineUnauthorized,
|
||||
@@ -99,6 +100,22 @@ func (nm *NetworkMap) User() tailcfg.UserID {
|
||||
return 0
|
||||
}
|
||||
|
||||
// GetAddresses returns the self node's addresses, or the zero value
|
||||
// if SelfNode is invalid.
|
||||
func (nm *NetworkMap) GetAddresses() views.Slice[netip.Prefix] {
|
||||
var zero views.Slice[netip.Prefix]
|
||||
if nm.Addresses != nil {
|
||||
// For now (2023-09-17), let the deprecated Addressees field take
|
||||
// precedence. This is a migration mechanism while we update tests &
|
||||
// code cross-repo.
|
||||
return views.SliceOf(nm.Addresses)
|
||||
}
|
||||
if !nm.SelfNode.Valid() {
|
||||
return zero
|
||||
}
|
||||
return nm.SelfNode.Addresses()
|
||||
}
|
||||
|
||||
// AnyPeersAdvertiseRoutes reports whether any peer is advertising non-exit node routes.
|
||||
func (nm *NetworkMap) AnyPeersAdvertiseRoutes() bool {
|
||||
for _, p := range nm.Peers {
|
||||
|
Reference in New Issue
Block a user