internal/clientinfo: use all possible source IP for listing clients

This commit is contained in:
Cuong Manh Le
2023-08-04 20:03:15 +00:00
committed by Cuong Manh Le
parent 46509be8a0
commit e5389ffecb
3 changed files with 32 additions and 5 deletions
+8 -3
View File
@@ -16,8 +16,6 @@ type IpResolver interface {
fmt.Stringer
// LookupIP returns ip of the device with given mac.
LookupIP(mac string) string
// List returns list of ip known by the resolver.
List() []string
}
// MacResolver is the interface for retrieving Mac from IP.
@@ -50,6 +48,12 @@ type refresher interface {
refresh() error
}
type ipLister interface {
fmt.Stringer
// List returns list of ip known by the resolver.
List() []string
}
type Client struct {
IP netip.Addr
Mac string
@@ -255,7 +259,8 @@ func (t *Table) ListClients() []*Client {
_ = r.refresh()
}
ipMap := make(map[string]*Client)
for _, ir := range t.ipResolvers {
il := []ipLister{t.dhcp, t.arp, t.ptr, t.mdns}
for _, ir := range il {
for _, ip := range ir.List() {
c, ok := ipMap[ip]
if !ok {