cherry-pick: 3142 swap arp and rdns priority
Merge in DNS/adguard-home from 3142-fix-clients to master Updates #3142. Updates #3597. Squashed commit of the following: commit 4dcabedbfb1a4e4a0aaba588f708e4625442fce8 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Mar 22 15:13:15 2022 +0300 all: imp log of changes commit 481088d05eecac1109daf378e0b4d5f6b2cf099b Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Mar 22 14:36:44 2022 +0300 all: swap arp and rdns priority
This commit is contained in:
parent
c4a13b92d2
commit
ba0cf5739b
|
@ -314,7 +314,7 @@ func (s *Server) Exchange(ip net.IP) (host string, err error) {
|
||||||
StartTime: time.Now(),
|
StartTime: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
resolver := s.internalProxy
|
var resolver *proxy.Proxy
|
||||||
if s.subnetDetector.IsLocallyServedNetwork(ip) {
|
if s.subnetDetector.IsLocallyServedNetwork(ip) {
|
||||||
if !s.conf.UsePrivateRDNS {
|
if !s.conf.UsePrivateRDNS {
|
||||||
return "", nil
|
return "", nil
|
||||||
|
@ -322,6 +322,8 @@ func (s *Server) Exchange(ip net.IP) (host string, err error) {
|
||||||
|
|
||||||
resolver = s.localResolvers
|
resolver = s.localResolvers
|
||||||
s.recDetector.add(*req)
|
s.recDetector.add(*req)
|
||||||
|
} else {
|
||||||
|
resolver = s.internalProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = resolver.Resolve(ctx); err != nil {
|
if err = resolver.Resolve(ctx); err != nil {
|
||||||
|
|
|
@ -56,8 +56,8 @@ type clientSource uint
|
||||||
// Client sources. The order determines the priority.
|
// Client sources. The order determines the priority.
|
||||||
const (
|
const (
|
||||||
ClientSourceWHOIS clientSource = iota
|
ClientSourceWHOIS clientSource = iota
|
||||||
ClientSourceRDNS
|
|
||||||
ClientSourceARP
|
ClientSourceARP
|
||||||
|
ClientSourceRDNS
|
||||||
ClientSourceDHCP
|
ClientSourceDHCP
|
||||||
ClientSourceHostsFile
|
ClientSourceHostsFile
|
||||||
)
|
)
|
||||||
|
@ -721,9 +721,7 @@ func (clients *clientsContainer) AddHost(ip net.IP, host string, src clientSourc
|
||||||
clients.lock.Lock()
|
clients.lock.Lock()
|
||||||
defer clients.lock.Unlock()
|
defer clients.lock.Unlock()
|
||||||
|
|
||||||
ok = clients.addHostLocked(ip, host, src)
|
return clients.addHostLocked(ip, host, src), nil
|
||||||
|
|
||||||
return ok, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// addHostLocked adds a new IP-hostname pairing. For internal use only.
|
// addHostLocked adds a new IP-hostname pairing. For internal use only.
|
||||||
|
|
|
@ -124,14 +124,12 @@ func (r *RDNS) workerLoop() {
|
||||||
log.Debug("rdns: resolving %q: %s", ip, err)
|
log.Debug("rdns: resolving %q: %s", ip, err)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
} else if host == "" {
|
||||||
|
|
||||||
if host == "" {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't handle any errors since AddHost doesn't return non-nil
|
// Don't handle any errors since AddHost doesn't return non-nil errors
|
||||||
// errors for now.
|
// for now.
|
||||||
_, _ = r.clients.AddHost(ip, host, ClientSourceRDNS)
|
_, _ = r.clients.AddHost(ip, host, ClientSourceRDNS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue