diff --git a/internal/dhcpd/bitset.go b/internal/dhcpd/bitset.go index e726319c..7459c2f1 100644 --- a/internal/dhcpd/bitset.go +++ b/internal/dhcpd/bitset.go @@ -25,11 +25,8 @@ func (s *bitSet) isSet(n uint64) (ok bool) { var word uint64 word, ok = s.words[wordIdx] - if !ok { - return false - } - return word&(1< src { - return false - } - - rc.Host = host - rc.Source = src - } else { + if !ok { rc = &RuntimeClient{ - Host: host, - Source: src, - WHOIS: &whois.Info{}, + WHOIS: &whois.Info{}, } clients.ipToRC[ip] = rc + } else if src < rc.Source { + return false } + rc.Host = host + rc.Source = src + log.Debug("clients: added %s -> %q [%d]", ip, host, len(clients.ipToRC)) return true @@ -827,38 +863,6 @@ func (clients *clientsContainer) addFromSystemARP() { log.Debug("clients: added %d client aliases from arp neighborhood", added) } -// updateFromDHCP adds the clients that have a non-empty hostname from the DHCP -// server. -func (clients *clientsContainer) updateFromDHCP(add bool) { - if clients.dhcpServer == nil || !config.Clients.Sources.DHCP { - return - } - - clients.lock.Lock() - defer clients.lock.Unlock() - - clients.rmHostsBySrc(ClientSourceDHCP) - - if !add { - return - } - - leases := clients.dhcpServer.Leases(dhcpd.LeasesAll) - n := 0 - for _, l := range leases { - if l.Hostname == "" { - continue - } - - ok := clients.addHostLocked(l.IP, l.Hostname, ClientSourceDHCP) - if ok { - n++ - } - } - - log.Debug("clients: added %d client aliases from dhcp", n) -} - // close gracefully closes all the client-specific upstream configurations of // the persistent clients. func (clients *clientsContainer) close() (err error) { diff --git a/internal/home/rdns_test.go b/internal/home/rdns_test.go index 4e424273..078a092f 100644 --- a/internal/home/rdns_test.go +++ b/internal/home/rdns_test.go @@ -228,12 +228,7 @@ func TestRDNS_WorkerLoop(t *testing.T) { for _, tc := range testCases { w.Reset() - cc := &clientsContainer{ - list: map[string]*Client{}, - idIndex: map[string]*Client{}, - ipToRC: map[netip.Addr]*RuntimeClient{}, - allTags: stringutil.NewSet(), - } + cc := newClientsContainer() ch := make(chan netip.Addr) rdns := &RDNS{ exchanger: &rDNSExchanger{