Sort by names, then IPs

This commit is contained in:
Ian Gulliver
2026-01-28 21:16:35 -08:00
parent 522b64450b
commit 7f36444003
3 changed files with 18 additions and 3 deletions

View File

@@ -124,7 +124,7 @@ locations:
- "ac:44:f2:4e:87:27" # MAIN2-R bridge interface - "ac:44:f2:4e:87:27" # MAIN2-R bridge interface
- ART6 # Wash - ART6 # Wash
- ART7 # Wash - ART7 # Wash
- DMX32 # Wash - DMX148 # wash6
- ART19 # Focus - ART19 # Focus
- name: Booth - name: Booth

View File

@@ -228,7 +228,13 @@ func (t *Tendrils) getNodes() []*Node {
nodes = append(nodes, node) nodes = append(nodes, node)
} }
sort.Slice(nodes, func(i, j int) bool { sort.Slice(nodes, func(i, j int) bool {
if nodes[i].DisplayName() != nodes[j].DisplayName() {
return sortorder.NaturalLess(nodes[i].DisplayName(), nodes[j].DisplayName()) return sortorder.NaturalLess(nodes[i].DisplayName(), nodes[j].DisplayName())
}
if nodes[i].FirstIP() != nodes[j].FirstIP() {
return sortorder.NaturalLess(nodes[i].FirstIP(), nodes[j].FirstIP())
}
return sortorder.NaturalLess(nodes[i].FirstMAC(), nodes[j].FirstMAC())
}) })
return nodes return nodes

View File

@@ -266,5 +266,14 @@ func (n *Node) FirstMAC() string {
return string(iface.MAC) return string(iface.MAC)
} }
} }
return "??" return ""
}
func (n *Node) FirstIP() string {
for _, iface := range n.Interfaces {
for ip := range iface.IPs {
return ip
}
}
return ""
} }