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:
16
types.go
16
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, "/")
|
||||
}
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user