mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-13 22:47:30 +00:00
types/netmap,wgengine/magicsock: propagate CapVer to magicsock.endpoint (#16244)
This enables us to mark nodes as relay capable or not. We don't actually do that yet, as we haven't established a relay CapVer. Updates tailscale/corp#27502 Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
@@ -69,6 +69,17 @@ func (m NodeMutationLastSeen) Apply(n *tailcfg.Node) {
|
||||
n.LastSeen = ptr.To(m.LastSeen)
|
||||
}
|
||||
|
||||
// NodeMutationCap is a NodeMutation that says a node's
|
||||
// [tailcfg.CapabilityVersion] value has changed.
|
||||
type NodeMutationCap struct {
|
||||
mutatingNodeID
|
||||
Cap tailcfg.CapabilityVersion
|
||||
}
|
||||
|
||||
func (m NodeMutationCap) Apply(n *tailcfg.Node) {
|
||||
n.Cap = m.Cap
|
||||
}
|
||||
|
||||
var peerChangeFields = sync.OnceValue(func() []reflect.StructField {
|
||||
var fields []reflect.StructField
|
||||
rt := reflect.TypeFor[tailcfg.PeerChange]()
|
||||
@@ -105,6 +116,8 @@ func NodeMutationsFromPatch(p *tailcfg.PeerChange) (_ []NodeMutation, ok bool) {
|
||||
ret = append(ret, NodeMutationOnline{mutatingNodeID(p.NodeID), *p.Online})
|
||||
case "LastSeen":
|
||||
ret = append(ret, NodeMutationLastSeen{mutatingNodeID(p.NodeID), *p.LastSeen})
|
||||
case "Cap":
|
||||
ret = append(ret, NodeMutationCap{mutatingNodeID(p.NodeID), p.Cap})
|
||||
}
|
||||
}
|
||||
return ret, true
|
||||
|
@@ -177,6 +177,14 @@ func TestMutationsFromMapResponse(t *testing.T) {
|
||||
},
|
||||
want: nil,
|
||||
},
|
||||
{
|
||||
name: "patch-cap",
|
||||
mr: fromChanges(&tailcfg.PeerChange{
|
||||
NodeID: 1,
|
||||
Cap: 2,
|
||||
}),
|
||||
want: muts(NodeMutationCap{1, 2}),
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
@@ -195,6 +203,7 @@ func TestMutationsFromMapResponse(t *testing.T) {
|
||||
NodeMutationDERPHome{},
|
||||
NodeMutationOnline{},
|
||||
NodeMutationLastSeen{},
|
||||
NodeMutationCap{},
|
||||
)); diff != "" {
|
||||
t.Errorf("wrong result (-want +got):\n%s", diff)
|
||||
}
|
||||
|
Reference in New Issue
Block a user