|
|
@ -40,7 +40,10 @@ type NetworkMap struct {
|
|
|
|
|
|
|
|
|
|
|
|
// MachineStatus is either tailcfg.MachineAuthorized or tailcfg.MachineUnauthorized,
|
|
|
|
// MachineStatus is either tailcfg.MachineAuthorized or tailcfg.MachineUnauthorized,
|
|
|
|
// depending on SelfNode.MachineAuthorized.
|
|
|
|
// depending on SelfNode.MachineAuthorized.
|
|
|
|
// TODO(bradfitz): remove this field and make it a method.
|
|
|
|
//
|
|
|
|
|
|
|
|
// Deprecated: use GetMachineStatus instead. This field exists still
|
|
|
|
|
|
|
|
// exists (as of 2023-09-13) for some tests in other repos that haven't
|
|
|
|
|
|
|
|
// yet been migrated. TODO(bradfitz): remove this field.
|
|
|
|
MachineStatus tailcfg.MachineStatus
|
|
|
|
MachineStatus tailcfg.MachineStatus
|
|
|
|
|
|
|
|
|
|
|
|
MachineKey key.MachinePublic
|
|
|
|
MachineKey key.MachinePublic
|
|
|
@ -106,6 +109,23 @@ func (nm *NetworkMap) AnyPeersAdvertiseRoutes() bool {
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GetMachineStatus returns the MachineStatus of the local node.
|
|
|
|
|
|
|
|
func (nm *NetworkMap) GetMachineStatus() tailcfg.MachineStatus {
|
|
|
|
|
|
|
|
if nm.MachineStatus != tailcfg.MachineUnknown {
|
|
|
|
|
|
|
|
// For now (2023-09-13), let the deprecated MachineStatus field take
|
|
|
|
|
|
|
|
// precedence. This is a migration mechanism while we update tests &
|
|
|
|
|
|
|
|
// code cross-repo.
|
|
|
|
|
|
|
|
return nm.MachineStatus
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if !nm.SelfNode.Valid() {
|
|
|
|
|
|
|
|
return tailcfg.MachineUnknown
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if nm.SelfNode.MachineAuthorized() {
|
|
|
|
|
|
|
|
return tailcfg.MachineAuthorized
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return tailcfg.MachineUnauthorized
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// PeerByTailscaleIP returns a peer's Node based on its Tailscale IP.
|
|
|
|
// PeerByTailscaleIP returns a peer's Node based on its Tailscale IP.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// If nm is nil or no peer is found, ok is false.
|
|
|
|
// If nm is nil or no peer is found, ok is false.
|
|
|
@ -211,7 +231,7 @@ func (nm *NetworkMap) PeerWithStableID(pid tailcfg.StableNodeID) (_ tailcfg.Node
|
|
|
|
// in equalConciseHeader in sync.
|
|
|
|
// in equalConciseHeader in sync.
|
|
|
|
func (nm *NetworkMap) printConciseHeader(buf *strings.Builder) {
|
|
|
|
func (nm *NetworkMap) printConciseHeader(buf *strings.Builder) {
|
|
|
|
fmt.Fprintf(buf, "netmap: self: %v auth=%v",
|
|
|
|
fmt.Fprintf(buf, "netmap: self: %v auth=%v",
|
|
|
|
nm.NodeKey.ShortString(), nm.MachineStatus)
|
|
|
|
nm.NodeKey.ShortString(), nm.GetMachineStatus())
|
|
|
|
login := nm.UserProfiles[nm.User()].LoginName
|
|
|
|
login := nm.UserProfiles[nm.User()].LoginName
|
|
|
|
if login == "" {
|
|
|
|
if login == "" {
|
|
|
|
if nm.User().IsZero() {
|
|
|
|
if nm.User().IsZero() {
|
|
|
@ -229,7 +249,7 @@ func (nm *NetworkMap) printConciseHeader(buf *strings.Builder) {
|
|
|
|
// used by printConciseHeader.
|
|
|
|
// used by printConciseHeader.
|
|
|
|
func (a *NetworkMap) equalConciseHeader(b *NetworkMap) bool {
|
|
|
|
func (a *NetworkMap) equalConciseHeader(b *NetworkMap) bool {
|
|
|
|
if a.NodeKey != b.NodeKey ||
|
|
|
|
if a.NodeKey != b.NodeKey ||
|
|
|
|
a.MachineStatus != b.MachineStatus ||
|
|
|
|
a.GetMachineStatus() != b.GetMachineStatus() ||
|
|
|
|
a.User() != b.User() ||
|
|
|
|
a.User() != b.User() ||
|
|
|
|
len(a.Addresses) != len(b.Addresses) {
|
|
|
|
len(a.Addresses) != len(b.Addresses) {
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|