Pull request 2223: 7013 Initial RDNS

Updates #7013.

Squashed commit of the following:

commit 68a53ec702ea4ba6c1e077eeea43a14cb93e76ff
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed May 22 15:55:31 2024 +0300

    all: imp chlog

commit a02b8e1165e05fbe96aea73dd238760e2b2fcce2
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed May 22 14:21:27 2024 +0300

    all: log changes, imp docs

commit f9ec0efe6dc8a257da8177b2e9bc41ed44b18bb7
Merge: ee7202a7b 1be34ab96
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed May 22 14:16:30 2024 +0300

    Merge branch 'master' into 7013-initial-rdns

commit ee7202a7b4
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed May 22 13:11:58 2024 +0300

    dnsforward: fix http rdns check

commit 5eaa024b11
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed May 22 12:40:30 2024 +0300

    all: fix initial rdns check
This commit is contained in:
Eugene Burkov 2024-05-22 16:40:28 +03:00
parent 1be34ab963
commit a030dd45d8
4 changed files with 22 additions and 10 deletions

View File

@ -23,6 +23,13 @@ See also the [v0.107.50 GitHub milestone][ms-v0.107.50].
NOTE: Add new changes BELOW THIS COMMENT.
-->
### Fixed
- Broken private reverse DNS upstream servers validation causing update failures
([#7013]).
[#7013]: https://github.com/AdguardTeam/AdGuardHome/issues/7013
<!--
NOTE: Add new changes ABOVE THIS COMMENT.
-->

View File

@ -333,6 +333,13 @@ func (req *jsonDNSConfig) checkBootstrap() (err error) {
return nil
}
// containsPrivateRDNS returns true if req contains private RDNS settings and
// should be validated.
func (req *jsonDNSConfig) containsPrivateRDNS() (ok bool) {
return (req.UsePrivateRDNS != nil && *req.UsePrivateRDNS) ||
(req.LocalPTRUpstreams != nil && len(*req.LocalPTRUpstreams) > 0)
}
// checkPrivateRDNS returns an error if the configuration of the private RDNS is
// not valid.
func (req *jsonDNSConfig) checkPrivateRDNS(
@ -340,7 +347,7 @@ func (req *jsonDNSConfig) checkPrivateRDNS(
sysResolvers SystemResolvers,
privateNets netutil.SubnetSet,
) (err error) {
if (req.UsePrivateRDNS == nil || !*req.UsePrivateRDNS) && req.LocalPTRUpstreams == nil {
if !req.containsPrivateRDNS() {
return nil
}

View File

@ -103,20 +103,18 @@ func newPrivateConfig(
}
}
log.Debug("dnsforward: upstreams to resolve ptr for local addresses: %v", addrs)
log.Debug("dnsforward: private-use upstreams: %v", addrs)
uc, err = proxy.ParseUpstreamsConfig(addrs, opts)
if err != nil {
return uc, fmt.Errorf("preparing private upstreams: %w", err)
}
if !confNeedsFiltering {
return uc, nil
}
err = filterOutAddrs(uc, unwanted)
if err != nil {
return uc, fmt.Errorf("filtering private upstreams: %w", err)
if confNeedsFiltering {
err = filterOutAddrs(uc, unwanted)
if err != nil {
return uc, fmt.Errorf("filtering private upstreams: %w", err)
}
}
// Prevalidate the config to catch the exact error before creating proxy.

View File

@ -156,7 +156,7 @@ func initDNSServer(
}
// Try to prepare the server with disabled private RDNS resolution if it
// failed to prepare as is. See TODO on [ErrBadPrivateRDNSUpstreams].
// failed to prepare as is. See TODO on [dnsforward.PrivateRDNSError].
err = Context.dnsServer.Prepare(dnsConf)
if privRDNSErr := (&dnsforward.PrivateRDNSError{}); errors.As(err, &privRDNSErr) {
log.Info("WARNING: %s; trying to disable private RDNS resolution", err)