Pull request: 2674 fix upstreams validation

Merge in DNS/adguard-home from 2674-quic-upstream to master

Updates #2674.

Squashed commit of the following:

commit ce7643580cc9e19881689e7fd4933bc953f2884e
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Tue Feb 16 18:23:39 2021 +0300

    all: fix log

commit b53e4368dd9ca61965e73b1f1274388422142830
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Tue Feb 16 18:21:59 2021 +0300

    all: log changes

commit 1cdca48e31c272ccfbde955c2a3e560ca6ca6bcf
Merge: bc441dac e32c18fa
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Tue Feb 16 18:15:47 2021 +0300

    Merge branch 'master' into 2674-quic-upstream

commit bc441dac3cbe8070c8c1d672925b14d309f05b9f
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Tue Feb 16 17:06:47 2021 +0300

    dnsforward: fix error wrapping

commit 281c1b43233c2bb51e3a933588087a207b7eef3d
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Tue Feb 16 17:00:35 2021 +0300

    all: fix validation, imp shutdown

commit 31a5ea7a081de4bcc3913bd04d62334fec1b59e1
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Tue Feb 16 14:53:10 2021 +0300

    dnsforward: fix upstreams validation
This commit is contained in:
Eugene Burkov 2021-02-16 18:46:49 +03:00
parent e32c18faab
commit 1122e71cf3
4 changed files with 10 additions and 1 deletions

View File

@ -19,8 +19,10 @@ and this project adheres to
### Fixed ### Fixed
- Incomplete DNS upstreams validation ([#2674]).
- Wrong parsing of DHCP options of the `ip` type ([#2688]). - Wrong parsing of DHCP options of the `ip` type ([#2688]).
[#2674]: https://github.com/AdguardTeam/AdGuardHome/issues/2674
[#2688]: https://github.com/AdguardTeam/AdGuardHome/issues/2688 [#2688]: https://github.com/AdguardTeam/AdGuardHome/issues/2688

View File

@ -282,7 +282,7 @@ func (s *Server) prepareUpstreamSettings() error {
} }
if len(upstreamConfig.Upstreams) == 0 { if len(upstreamConfig.Upstreams) == 0 {
log.Info("Warning: no default upstream servers specified, using %v", defaultDNS) log.Info("warning: no default upstream servers specified, using %v", defaultDNS)
uc, err := proxy.ParseUpstreamsConfig(defaultDNS, s.conf.BootstrapDNS, DefaultTimeout) uc, err := proxy.ParseUpstreamsConfig(defaultDNS, s.conf.BootstrapDNS, DefaultTimeout)
if err != nil { if err != nil {
return fmt.Errorf("dns: failed to parse default upstreams: %v", err) return fmt.Errorf("dns: failed to parse default upstreams: %v", err)

View File

@ -8,6 +8,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/AdguardTeam/dnsproxy/proxy"
"github.com/AdguardTeam/dnsproxy/upstream" "github.com/AdguardTeam/dnsproxy/upstream"
"github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/log"
"github.com/AdguardTeam/golibs/utils" "github.com/AdguardTeam/golibs/utils"
@ -314,6 +315,11 @@ func ValidateUpstreams(upstreams []string) error {
return nil return nil
} }
_, err := proxy.ParseUpstreamsConfig(upstreams, []string{}, DefaultTimeout)
if err != nil {
return err
}
var defaultUpstreamFound bool var defaultUpstreamFound bool
for _, u := range upstreams { for _, u := range upstreams {
d, err := validateUpstream(u) d, err := validateUpstream(u)

View File

@ -320,6 +320,7 @@ func run(args options) {
go func() { go func() {
err := startDNSServer() err := startDNSServer()
if err != nil { if err != nil {
closeDNSServer()
log.Fatal(err) log.Fatal(err)
} }
}() }()