diff --git a/hscontrol/types/node.go b/hscontrol/types/node.go index 84932c895..c632de16f 100644 --- a/hscontrol/types/node.go +++ b/hscontrol/types/node.go @@ -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] diff --git a/hscontrol/types/types_clone.go b/hscontrol/types/types_clone.go index 011704e73..76408a494 100644 --- a/hscontrol/types/types_clone.go +++ b/hscontrol/types/types_clone.go @@ -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. diff --git a/hscontrol/types/types_view.go b/hscontrol/types/types_view.go index 43678d466..182827b3b 100644 --- a/hscontrol/types/types_view.go +++ b/hscontrol/types/types_view.go @@ -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.