From 481088d05eecac1109daf378e0b4d5f6b2cf099b Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Tue, 22 Mar 2022 14:36:44 +0300 Subject: [PATCH] all: swap arp and rdns priority --- CHANGELOG.md | 2 ++ internal/dnsforward/dnsforward.go | 4 +++- internal/home/clients.go | 6 ++---- internal/home/rdns.go | 8 +++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d663d78eb68..0c72c7188f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ and this project adheres to ### Changed +- Reverse DNS now has a greater priority as the source of client's informmation + than ARP neighborhood. - Improved detection of runtime clients through more resilient ARP processing ([#3597]). - The TTL of responses served from the optimistic cache is now lowered to 10 diff --git a/internal/dnsforward/dnsforward.go b/internal/dnsforward/dnsforward.go index 48e344b3c4a..a5b0098a7d7 100644 --- a/internal/dnsforward/dnsforward.go +++ b/internal/dnsforward/dnsforward.go @@ -314,7 +314,7 @@ func (s *Server) Exchange(ip net.IP) (host string, err error) { StartTime: time.Now(), } - resolver := s.internalProxy + var resolver *proxy.Proxy if s.privateNets.Contains(ip) { if !s.conf.UsePrivateRDNS { return "", nil @@ -322,6 +322,8 @@ func (s *Server) Exchange(ip net.IP) (host string, err error) { resolver = s.localResolvers s.recDetector.add(*req) + } else { + resolver = s.internalProxy } if err = resolver.Resolve(ctx); err != nil { diff --git a/internal/home/clients.go b/internal/home/clients.go index d9aad40ec08..08d70bb966e 100644 --- a/internal/home/clients.go +++ b/internal/home/clients.go @@ -53,8 +53,8 @@ type clientSource uint // Client sources. The order determines the priority. const ( ClientSourceWHOIS clientSource = iota - ClientSourceRDNS ClientSourceARP + ClientSourceRDNS ClientSourceDHCP ClientSourceHostsFile ) @@ -723,9 +723,7 @@ func (clients *clientsContainer) AddHost(ip net.IP, host string, src clientSourc clients.lock.Lock() defer clients.lock.Unlock() - ok = clients.addHostLocked(ip, host, src) - - return ok, nil + return clients.addHostLocked(ip, host, src), nil } // addHostLocked adds a new IP-hostname pairing. For internal use only. diff --git a/internal/home/rdns.go b/internal/home/rdns.go index cba748affa1..7a2d1bcdc73 100644 --- a/internal/home/rdns.go +++ b/internal/home/rdns.go @@ -125,14 +125,12 @@ func (r *RDNS) workerLoop() { log.Debug("rdns: resolving %q: %s", ip, err) continue - } - - if host == "" { + } else if host == "" { continue } - // Don't handle any errors since AddHost doesn't return non-nil - // errors for now. + // Don't handle any errors since AddHost doesn't return non-nil errors + // for now. _, _ = r.clients.AddHost(ip, host, ClientSourceRDNS) } }