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,15 +239,25 @@ 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
for name := range n.Names {
names = append(names, name)
}
sortNamesByLength(names)
return strings.Join(names, "/")
} }
var names []string for _, iface := range n.Interfaces {
for name := range n.Names { for ip := range iface.IPs {
names = append(names, name) return ip
}
} }
sortNamesByLength(names) for _, iface := range n.Interfaces {
return strings.Join(names, "/") if iface.MAC != "" {
return string(iface.MAC)
}
}
return ""
} }
func (n *Node) FirstMAC() string { func (n *Node) FirstMAC() string {