mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-04 01:07:49 +02:00
internal/clientinfo: use all possible source IP for listing clients
This commit is contained in:
committed by
Cuong Manh Le
parent
46509be8a0
commit
e5389ffecb
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user