Skip to content

Commit

Permalink
all: swap arp and rdns priority
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Mar 22, 2022
1 parent b9790f6 commit 481088d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion internal/dnsforward/dnsforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,16 @@ 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
}

resolver = s.localResolvers
s.recDetector.add(*req)
} else {
resolver = s.internalProxy
}

if err = resolver.Resolve(ctx); err != nil {
Expand Down
6 changes: 2 additions & 4 deletions internal/home/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ type clientSource uint
// Client sources. The order determines the priority.
const (
ClientSourceWHOIS clientSource = iota
ClientSourceRDNS
ClientSourceARP
ClientSourceRDNS
ClientSourceDHCP
ClientSourceHostsFile
)
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 3 additions & 5 deletions internal/home/rdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 481088d

Please sign in to comment.