mirror of
https://github.com/tailscale/tailscale.git
synced 2025-05-16 07:19:53 +00:00
tailcfg: add StableID to Node. #1178
Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
parent
54d0d83b67
commit
49d00b6a28
@ -35,6 +35,8 @@ import (
|
|||||||
// 10: 2021-01-17: client understands MapResponse.PeerSeenChange
|
// 10: 2021-01-17: client understands MapResponse.PeerSeenChange
|
||||||
const CurrentMapRequestVersion = 10
|
const CurrentMapRequestVersion = 10
|
||||||
|
|
||||||
|
type StableID string
|
||||||
|
|
||||||
type ID int64
|
type ID int64
|
||||||
|
|
||||||
type UserID ID
|
type UserID ID
|
||||||
@ -55,6 +57,12 @@ func (u NodeID) IsZero() bool {
|
|||||||
return u == 0
|
return u == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type StableNodeID StableID
|
||||||
|
|
||||||
|
func (u StableNodeID) IsZero() bool {
|
||||||
|
return u == ""
|
||||||
|
}
|
||||||
|
|
||||||
type GroupID ID
|
type GroupID ID
|
||||||
|
|
||||||
func (u GroupID) IsZero() bool {
|
func (u GroupID) IsZero() bool {
|
||||||
@ -148,8 +156,9 @@ type UserProfile struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Node struct {
|
type Node struct {
|
||||||
ID NodeID
|
ID NodeID
|
||||||
Name string // DNS
|
StableID StableNodeID
|
||||||
|
Name string // DNS
|
||||||
|
|
||||||
// User is the user who created the node. If ACL tags are in
|
// User is the user who created the node. If ACL tags are in
|
||||||
// use for the node then it doesn't reflect the ACL identity
|
// use for the node then it doesn't reflect the ACL identity
|
||||||
@ -785,6 +794,7 @@ func (n *Node) Equal(n2 *Node) bool {
|
|||||||
}
|
}
|
||||||
return n != nil && n2 != nil &&
|
return n != nil && n2 != nil &&
|
||||||
n.ID == n2.ID &&
|
n.ID == n2.ID &&
|
||||||
|
n.StableID == n2.StableID &&
|
||||||
n.Name == n2.Name &&
|
n.Name == n2.Name &&
|
||||||
n.User == n2.User &&
|
n.User == n2.User &&
|
||||||
n.Sharer == n2.Sharer &&
|
n.Sharer == n2.Sharer &&
|
||||||
|
@ -62,6 +62,7 @@ func (src *Node) Clone() *Node {
|
|||||||
// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig,RegisterResponse
|
// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig,RegisterResponse
|
||||||
var _NodeNeedsRegeneration = Node(struct {
|
var _NodeNeedsRegeneration = Node(struct {
|
||||||
ID NodeID
|
ID NodeID
|
||||||
|
StableID StableNodeID
|
||||||
Name string
|
Name string
|
||||||
User UserID
|
User UserID
|
||||||
Sharer UserID
|
Sharer UserID
|
||||||
|
@ -189,7 +189,7 @@ func TestHostinfoEqual(t *testing.T) {
|
|||||||
|
|
||||||
func TestNodeEqual(t *testing.T) {
|
func TestNodeEqual(t *testing.T) {
|
||||||
nodeHandles := []string{
|
nodeHandles := []string{
|
||||||
"ID", "Name", "User", "Sharer",
|
"ID", "StableID", "Name", "User", "Sharer",
|
||||||
"Key", "KeyExpiry", "Machine", "DiscoKey",
|
"Key", "KeyExpiry", "Machine", "DiscoKey",
|
||||||
"Addresses", "AllowedIPs", "Endpoints", "DERP", "Hostinfo",
|
"Addresses", "AllowedIPs", "Endpoints", "DERP", "Hostinfo",
|
||||||
"Created", "LastSeen", "KeepAlive", "MachineAuthorized",
|
"Created", "LastSeen", "KeepAlive", "MachineAuthorized",
|
||||||
@ -229,6 +229,31 @@ func TestNodeEqual(t *testing.T) {
|
|||||||
&Node{},
|
&Node{},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
&Node{},
|
||||||
|
&Node{},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
&Node{ID: 1},
|
||||||
|
&Node{},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
&Node{ID: 1},
|
||||||
|
&Node{ID: 1},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
&Node{StableID: "node-abcd"},
|
||||||
|
&Node{},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
&Node{StableID: "node-abcd"},
|
||||||
|
&Node{StableID: "node-abcd"},
|
||||||
|
true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
&Node{User: 0},
|
&Node{User: 0},
|
||||||
&Node{User: 1},
|
&Node{User: 1},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user