Fall back to IP or MAC in DisplayName when no names available

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ian Gulliver
2026-01-26 14:50:55 -08:00
parent 0baa208b99
commit 5ec5e8e3e5

View File

@@ -239,9 +239,7 @@ func (n *Node) String() string {
} }
func (n *Node) DisplayName() string { func (n *Node) DisplayName() string {
if len(n.Names) == 0 { if len(n.Names) > 0 {
return ""
}
var names []string var names []string
for name := range n.Names { for name := range n.Names {
names = append(names, name) names = append(names, name)
@@ -249,6 +247,18 @@ func (n *Node) DisplayName() string {
sortNamesByLength(names) sortNamesByLength(names)
return strings.Join(names, "/") return strings.Join(names, "/")
} }
for _, iface := range n.Interfaces {
for ip := range iface.IPs {
return ip
}
}
for _, iface := range n.Interfaces {
if iface.MAC != "" {
return string(iface.MAC)
}
}
return ""
}
func (n *Node) FirstMAC() string { func (n *Node) FirstMAC() string {
for _, iface := range n.Interfaces { for _, iface := range n.Interfaces {