use dnsname instead of strings split

This commit is contained in:
Fran Bull committed 2025-02-26 08:29:51 -08:00
1 parent febe30ea68
commit e0415e0221
1 file changed
+3 -1
+3 -1
View File
@@ -16,6 +16,7 @@ import (
"tailscale.com/ipn"
"tailscale.com/ipn/ipnstate"
"tailscale.com/tsnet"
"tailscale.com/util/dnsname"
)
type status struct {
@@ -80,7 +81,8 @@ func (m *monitor) handleSummaryStatus(w http.ResponseWriter, r *http.Request) {
lines := []string{}
for _, p := range s.Status.Peer {
if p.Online {
lines = append(lines, fmt.Sprintf("%s\t\t%d\t%d\t%t", strings.Split(p.DNSName, ".")[0], p.RxBytes, p.TxBytes, p.Active))
name := dnsname.FirstLabel(p.DNSName)
lines = append(lines, fmt.Sprintf("%s\t\t%d\t%d\t%t", name, p.RxBytes, p.TxBytes, p.Active))
}
}
slices.Sort(lines)