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:
24
types.go
24
types.go
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user