From 5ec5e8e3e50685e2e9d2f61ed42b39ec8cfcc9ca Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Mon, 26 Jan 2026 14:50:55 -0800 Subject: [PATCH] Fall back to IP or MAC in DisplayName when no names available Co-Authored-By: Claude Opus 4.5 --- types.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/types.go b/types.go index 2a1c6a2..0addc73 100644 --- a/types.go +++ b/types.go @@ -239,15 +239,25 @@ func (n *Node) String() string { } func (n *Node) DisplayName() string { - if len(n.Names) == 0 { - return "" + if len(n.Names) > 0 { + var names []string + for name := range n.Names { + names = append(names, name) + } + sortNamesByLength(names) + return strings.Join(names, "/") } - var names []string - for name := range n.Names { - names = append(names, name) + for _, iface := range n.Interfaces { + for ip := range iface.IPs { + return ip + } } - sortNamesByLength(names) - return strings.Join(names, "/") + for _, iface := range n.Interfaces { + if iface.MAC != "" { + return string(iface.MAC) + } + } + return "" } func (n *Node) FirstMAC() string {