wgengine/netlog: strip dot suffix from node name (#17954)

The REST API does not return a node name
with a trailing dot, while the internal node name
reported in the netmap does have one.

In order to be consistent with the API,
strip the dot when recording node information.

Updates tailscale/corp#33352

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
Joe Tsai 2025-11-17 19:17:02 -08:00 committed by GitHub
parent 41662f5128
commit 4860c460f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View File

@ -9,6 +9,7 @@ import (
"cmp"
"net/netip"
"slices"
"strings"
"time"
"unicode/utf8"
@ -169,7 +170,10 @@ func (nu nodeUser) toNode() netlogtype.Node {
if !nu.Valid() {
return netlogtype.Node{}
}
n := netlogtype.Node{NodeID: nu.StableID(), Name: nu.Name()}
n := netlogtype.Node{
NodeID: nu.StableID(),
Name: strings.TrimSuffix(nu.Name(), "."),
}
var ipv4, ipv6 netip.Addr
for _, addr := range nu.Addresses().All() {
switch {

View File

@ -53,7 +53,7 @@ func TestToMessage(t *testing.T) {
selfNode: nodeUser{NodeView: (&tailcfg.Node{
ID: 123456,
StableID: "n123456CNTL",
Name: "src.tail123456.ts.net",
Name: "src.tail123456.ts.net.",
Addresses: []netip.Prefix{prefix("100.1.2.3")},
Tags: []string{"tag:src"},
}).View()},
@ -64,14 +64,14 @@ func TestToMessage(t *testing.T) {
addr("100.1.2.4"): {NodeView: (&tailcfg.Node{
ID: 123457,
StableID: "n123457CNTL",
Name: "dst1.tail123456.ts.net",
Name: "dst1.tail123456.ts.net.",
Addresses: []netip.Prefix{prefix("100.1.2.4")},
Tags: []string{"tag:dst1"},
}).View()},
addr("100.1.2.5"): {NodeView: (&tailcfg.Node{
ID: 123458,
StableID: "n123458CNTL",
Name: "dst2.tail123456.ts.net",
Name: "dst2.tail123456.ts.net.",
Addresses: []netip.Prefix{prefix("100.1.2.5")},
Tags: []string{"tag:dst2"},
}).View()},
@ -163,7 +163,7 @@ func TestToNode(t *testing.T) {
{
node: &tailcfg.Node{
StableID: "n123456CNTL",
Name: "test.tail123456.ts.net",
Name: "test.tail123456.ts.net.",
Addresses: []netip.Prefix{prefix("100.1.2.3")},
Tags: []string{"tag:dupe", "tag:test", "tag:dupe"},
User: 12345, // should be ignored