types: add runtime Node.CapVer, drop unused TailNodes

TailNodes stamped one capability version on every peer.
This commit is contained in:
Kristoffer Dalby committed 2026-11-20 16:56:53 +01:00
1 parent 3ad8f889d8
commit 8c1c2d5020
3 files changed
+19 -24

No files matched your search

+8 -23
View File
@@ -234,6 +234,14 @@ type Node struct {
// overlapping reconnect keeps it. Primary election prefers the
// oldest. Runtime-only.
SessionStart time.Time `gorm:"-"`
// CapVer is the capability version from the node's latest MapRequest,
// sent to peers as [tailcfg.Node.Cap]. Clients gate peer protocol
// features on it (e.g. hybrid WireGuard handshakes), so peers must see
// the node's own version, never the viewer's. 0 until the node sends a
// MapRequest, which clients read as "nothing new supported".
// Runtime-only.
CapVer tailcfg.CapabilityVersion `gorm:"-"`
}
type Nodes []*Node
@@ -1340,29 +1348,6 @@ func (nv NodeView) HasPolicyChange(other NodeView) bool {
return false
}
// TailNodes converts a slice of [NodeView] values into Tailscale [tailcfg.Node] values.
func TailNodes(
nodes views.Slice[NodeView],
capVer tailcfg.CapabilityVersion,
primaryRouteFunc RouteFunc,
cfg *Config,
) ([]*tailcfg.Node, error) {
tNodes := make([]*tailcfg.Node, 0, nodes.Len())
for _, node := range nodes.All() {
// nil selfPolicyCaps: this batch builds peer views; the caller
// sets each peer's CapMap from [policyv2.PeerCapMap].
tNode, err := node.TailNode(capVer, primaryRouteFunc, cfg, nil)
if err != nil {
return nil, err
}
tNodes = append(tNodes, tNode)
}
return tNodes, nil
}
// TailNode converts a [NodeView] into a Tailscale [tailcfg.Node].
//
// selfPolicyCaps is the per-node CapMap from [policy.PolicyManager.NodeCapMap]
+1
View File
@@ -116,6 +116,7 @@ var _NodeCloneNeedsRegeneration = Node(struct {
ActiveSessions int
SessionEpoch uint64
SessionStart time.Time
CapVer tailcfg.CapabilityVersion
}{})
// Clone makes a deep copy of PreAuthKey.
+10 -1
View File
@@ -305,7 +305,15 @@ func (v NodeView) SessionEpoch() uint64 { return v.ж.SessionEpoch }
// overlapping reconnect keeps it. Primary election prefers the
// oldest. Runtime-only.
func (v NodeView) SessionStart() time.Time { return v.ж.SessionStart }
func (v NodeView) String() string { return v.ж.String() }
// CapVer is the capability version from the node's latest MapRequest,
// sent to peers as [tailcfg.Node.Cap]. Clients gate peer protocol
// features on it (e.g. hybrid WireGuard handshakes), so peers must see
// the node's own version, never the viewer's. 0 until the node sends a
// MapRequest, which clients read as "nothing new supported".
// Runtime-only.
func (v NodeView) CapVer() tailcfg.CapabilityVersion { return v.ж.CapVer }
func (v NodeView) String() string { return v.ж.String() }
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _NodeViewNeedsRegeneration = Node(struct {
@@ -339,6 +347,7 @@ var _NodeViewNeedsRegeneration = Node(struct {
ActiveSessions int
SessionEpoch uint64
SessionStart time.Time
CapVer tailcfg.CapabilityVersion
}{})
// View returns a read-only view of PreAuthKey.