1
0
mirror of https://github.com/juanfont/headscale.git synced 2026-02-23 13:50:36 +01:00
This commit is contained in:
Ali Mohammed 2026-02-19 14:57:46 -08:00 committed by GitHub
commit bc22686ecb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 58 additions and 0 deletions

View File

@ -513,6 +513,7 @@ func nodesToPtables(
"Expiration",
"Connected",
"Expired",
"Client Version",
}
tableData := pterm.TableData{tableHeader}
@ -623,6 +624,7 @@ func nodesToPtables(
expiryTime,
online,
expired,
node.GetClientVersion(),
}
tableData = append(
tableData,

View File

@ -98,6 +98,7 @@ type Node struct {
AvailableRoutes []string `protobuf:"bytes,24,rep,name=available_routes,json=availableRoutes,proto3" json:"available_routes,omitempty"`
SubnetRoutes []string `protobuf:"bytes,25,rep,name=subnet_routes,json=subnetRoutes,proto3" json:"subnet_routes,omitempty"`
Tags []string `protobuf:"bytes,26,rep,name=tags,proto3" json:"tags,omitempty"`
ClientVersion string `protobuf:"bytes,27,opt,name=client_version,json=clientVersion,proto3" json:"client_version,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@ -258,6 +259,13 @@ func (x *Node) GetTags() []string {
return nil
}
func (x *Node) GetClientVersion() string {
if x != nil {
return x.ClientVersion
}
return ""
}
type RegisterNodeRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`

View File

@ -424,6 +424,10 @@ func (node *Node) Proto() *v1.Node {
nodeProto.Expiry = timestamppb.New(*node.Expiry)
}
if node.Hostinfo != nil {
nodeProto.ClientVersion = node.Hostinfo.View().IPNVersion()
}
return nodeProto
}

View File

@ -969,3 +969,46 @@ func TestHasNetworkChanges(t *testing.T) {
})
}
}
func TestNodeProto_ClientVersion(t *testing.T) {
tests := []struct {
name string
hostinfo *tailcfg.Hostinfo
wantVersion string
}{
{
name: "node-with-client-version",
hostinfo: &tailcfg.Hostinfo{IPNVersion: "1.50.0"},
wantVersion: "1.50.0",
},
{
name: "node-with-different-version",
hostinfo: &tailcfg.Hostinfo{IPNVersion: "1.76.1"},
wantVersion: "1.76.1",
},
{
name: "node-without-hostinfo",
hostinfo: nil,
wantVersion: "",
},
{
name: "node-with-empty-version",
hostinfo: &tailcfg.Hostinfo{IPNVersion: ""},
wantVersion: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
node := &Node{
ID: 1,
Hostname: "test-node",
Hostinfo: tt.hostinfo,
}
proto := node.Proto()
if got := proto.GetClientVersion(); got != tt.wantVersion {
t.Errorf("Proto().GetClientVersion() = %q, want %q", got, tt.wantVersion)
}
})
}
}

View File

@ -53,6 +53,7 @@ message Node {
repeated string available_routes = 24;
repeated string subnet_routes = 25;
repeated string tags = 26;
string client_version = 27;
}
message RegisterNodeRequest {