transport should try ipv4 then ipv6 explicitly

client list panic guards and debug logging
This commit is contained in:
Alex
2025-02-20 23:37:44 -05:00
committed by Cuong Manh Le
parent b05056423a
commit 49eb152d02
6 changed files with 180 additions and 21 deletions
+18 -8
View File
@@ -422,17 +422,27 @@ func (t *Table) ListClients() []*Client {
t.Refresh()
ipMap := make(map[string]*Client)
il := []ipLister{t.dhcp, t.arp, t.ndp, t.ptr, t.mdns, t.vni}
for _, ir := range il {
if ir == nil {
continue
}
for _, ip := range ir.List() {
c, ok := ipMap[ip]
if !ok {
c = &Client{
IP: netip.MustParseAddr(ip),
Source: map[string]struct{}{ir.String(): {}},
// Validate IP before using MustParseAddr
if addr, err := netip.ParseAddr(ip); err == nil {
c, ok := ipMap[ip]
if !ok {
c = &Client{
IP: addr,
Source: map[string]struct{}{},
}
ipMap[ip] = c
}
// Safely get source name
if src := ir.String(); src != "" {
c.Source[src] = struct{}{}
}
ipMap[ip] = c
} else {
c.Source[ir.String()] = struct{}{}
}
}
}