mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
tailcfg: add Node.PrimaryRoutes
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
1b14e1d6bd
commit
d8d9036dbb
@ -164,6 +164,12 @@ type Node struct {
|
|||||||
Hostinfo Hostinfo
|
Hostinfo Hostinfo
|
||||||
Created time.Time
|
Created time.Time
|
||||||
|
|
||||||
|
// PrimaryRoutes are the routes from AllowedIPs that this node
|
||||||
|
// is currently the primary subnet router for, as determined
|
||||||
|
// by the control plane. It does not include the self address
|
||||||
|
// values from Addresses that are in AllowedIPs.
|
||||||
|
PrimaryRoutes []netaddr.IPPrefix `json:",omitempty"`
|
||||||
|
|
||||||
// LastSeen is when the node was last online. It is not
|
// LastSeen is when the node was last online. It is not
|
||||||
// updated when Online is true. It is nil if the current
|
// updated when Online is true. It is nil if the current
|
||||||
// node doesn't have permission to know, or the node
|
// node doesn't have permission to know, or the node
|
||||||
@ -1142,6 +1148,7 @@ func (n *Node) Equal(n2 *Node) bool {
|
|||||||
eqBoolPtr(n.Online, n2.Online) &&
|
eqBoolPtr(n.Online, n2.Online) &&
|
||||||
eqCIDRs(n.Addresses, n2.Addresses) &&
|
eqCIDRs(n.Addresses, n2.Addresses) &&
|
||||||
eqCIDRs(n.AllowedIPs, n2.AllowedIPs) &&
|
eqCIDRs(n.AllowedIPs, n2.AllowedIPs) &&
|
||||||
|
eqCIDRs(n.PrimaryRoutes, n2.PrimaryRoutes) &&
|
||||||
eqStrings(n.Endpoints, n2.Endpoints) &&
|
eqStrings(n.Endpoints, n2.Endpoints) &&
|
||||||
n.DERP == n2.DERP &&
|
n.DERP == n2.DERP &&
|
||||||
n.Hostinfo.Equal(&n2.Hostinfo) &&
|
n.Hostinfo.Equal(&n2.Hostinfo) &&
|
||||||
|
@ -49,6 +49,7 @@ func (src *Node) Clone() *Node {
|
|||||||
dst.AllowedIPs = append(src.AllowedIPs[:0:0], src.AllowedIPs...)
|
dst.AllowedIPs = append(src.AllowedIPs[:0:0], src.AllowedIPs...)
|
||||||
dst.Endpoints = append(src.Endpoints[:0:0], src.Endpoints...)
|
dst.Endpoints = append(src.Endpoints[:0:0], src.Endpoints...)
|
||||||
dst.Hostinfo = *src.Hostinfo.Clone()
|
dst.Hostinfo = *src.Hostinfo.Clone()
|
||||||
|
dst.PrimaryRoutes = append(src.PrimaryRoutes[:0:0], src.PrimaryRoutes...)
|
||||||
if dst.LastSeen != nil {
|
if dst.LastSeen != nil {
|
||||||
dst.LastSeen = new(time.Time)
|
dst.LastSeen = new(time.Time)
|
||||||
*dst.LastSeen = *src.LastSeen
|
*dst.LastSeen = *src.LastSeen
|
||||||
@ -79,6 +80,7 @@ func (src *Node) Clone() *Node {
|
|||||||
DERP string
|
DERP string
|
||||||
Hostinfo Hostinfo
|
Hostinfo Hostinfo
|
||||||
Created time.Time
|
Created time.Time
|
||||||
|
PrimaryRoutes []netaddr.IPPrefix
|
||||||
LastSeen *time.Time
|
LastSeen *time.Time
|
||||||
Online *bool
|
Online *bool
|
||||||
KeepAlive bool
|
KeepAlive bool
|
||||||
|
@ -194,7 +194,8 @@ func TestNodeEqual(t *testing.T) {
|
|||||||
"ID", "StableID", "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", "Online", "KeepAlive", "MachineAuthorized",
|
"Created", "PrimaryRoutes",
|
||||||
|
"LastSeen", "Online", "KeepAlive", "MachineAuthorized",
|
||||||
"Capabilities",
|
"Capabilities",
|
||||||
"ComputedName", "computedHostIfDifferent", "ComputedNameWithHost",
|
"ComputedName", "computedHostIfDifferent", "ComputedNameWithHost",
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user