Pull request: 2600 inconsistent response
Merge in DNS/adguard-home from 2600-upd-dnsproxy to master Closes #2600. Squashed commit of the following: commit 4b1515395841f14d86bc85b5c516d14919b5dc25 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Mar 2 18:39:19 2021 +0300 all: upd dnsproxy again, log changes commit 8a866201f140655b0d2f58552a7ad9bcae91a173 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Mar 2 14:53:48 2021 +0300 all: cleanup commit ae81234c79a6dbc61cccbae9c1b9d0144bb7f506 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Mar 2 14:49:28 2021 +0300 all: fix deps commit 662384c366feaf553d9eba2b5e3be93774631ec5 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Mar 2 13:58:26 2021 +0300 all: upd dnsproxy version, fix functions' signatures
This commit is contained in:
@@ -276,14 +276,24 @@ func (s *Server) prepareUpstreamSettings() error {
|
||||
upstreams = s.conf.UpstreamDNS
|
||||
}
|
||||
upstreams = filterOutComments(upstreams)
|
||||
upstreamConfig, err := proxy.ParseUpstreamsConfig(upstreams, s.conf.BootstrapDNS, DefaultTimeout)
|
||||
upstreamConfig, err := proxy.ParseUpstreamsConfig(upstreams,
|
||||
upstream.Options{
|
||||
Bootstrap: s.conf.BootstrapDNS,
|
||||
Timeout: DefaultTimeout,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dns: proxy.ParseUpstreamsConfig: %w", err)
|
||||
}
|
||||
|
||||
if len(upstreamConfig.Upstreams) == 0 {
|
||||
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,
|
||||
upstream.Options{
|
||||
Bootstrap: s.conf.BootstrapDNS,
|
||||
Timeout: DefaultTimeout,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dns: failed to parse default upstreams: %v", err)
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func (req *dnsConfig) checkBootstrap() (string, error) {
|
||||
return boot, fmt.Errorf("invalid bootstrap server address: empty")
|
||||
}
|
||||
|
||||
if _, err := upstream.NewResolver(boot, 0); err != nil {
|
||||
if _, err := upstream.NewResolver(boot, upstream.Options{Timeout: 0}); err != nil {
|
||||
return boot, fmt.Errorf("invalid bootstrap server address: %w", err)
|
||||
}
|
||||
}
|
||||
@@ -315,7 +315,12 @@ func ValidateUpstreams(upstreams []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := proxy.ParseUpstreamsConfig(upstreams, []string{}, DefaultTimeout)
|
||||
_, err := proxy.ParseUpstreamsConfig(upstreams,
|
||||
upstream.Options{
|
||||
Bootstrap: []string{},
|
||||
Timeout: DefaultTimeout,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/dnsforward"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/util"
|
||||
"github.com/AdguardTeam/dnsproxy/proxy"
|
||||
"github.com/AdguardTeam/dnsproxy/upstream"
|
||||
"github.com/AdguardTeam/golibs/log"
|
||||
"github.com/AdguardTeam/golibs/utils"
|
||||
)
|
||||
@@ -295,7 +296,12 @@ func (clients *clientsContainer) FindUpstreams(ip string) *proxy.UpstreamConfig
|
||||
}
|
||||
|
||||
if c.upstreamConfig == nil {
|
||||
config, err := proxy.ParseUpstreamsConfig(c.Upstreams, config.DNS.BootstrapDNS, dnsforward.DefaultTimeout)
|
||||
config, err := proxy.ParseUpstreamsConfig(c.Upstreams,
|
||||
upstream.Options{
|
||||
Bootstrap: config.DNS.BootstrapDNS,
|
||||
Timeout: dnsforward.DefaultTimeout,
|
||||
},
|
||||
)
|
||||
if err == nil {
|
||||
c.upstreamConfig = &config
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ func TestHome(t *testing.T) {
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
// test DNS over UDP
|
||||
r, err := upstream.NewResolver("127.0.0.1:5354", 3*time.Second)
|
||||
r, err := upstream.NewResolver("127.0.0.1:5354", upstream.Options{Timeout: 3 * time.Second})
|
||||
assert.Nil(t, err)
|
||||
addrs, err := r.LookupIPAddr(context.TODO(), "static.adguard.com")
|
||||
assert.Nil(t, err)
|
||||
|
||||
Reference in New Issue
Block a user