From 88c67764b9515902514b0a8e4f00af29a353c584 Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Wed, 9 Sep 2020 18:12:11 +0300 Subject: [PATCH] * (dnsforward): don't fail when default upstream is not set --- dnsforward/config.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dnsforward/config.go b/dnsforward/config.go index c66406ac..5e4fe170 100644 --- a/dnsforward/config.go +++ b/dnsforward/config.go @@ -187,7 +187,7 @@ func (s *Server) createProxyConfig() (proxy.Config, error) { // Validate proxy config if proxyConfig.UpstreamConfig == nil || len(proxyConfig.UpstreamConfig.Upstreams) == 0 { - return proxyConfig, errors.New("no upstream servers configured") + return proxyConfig, errors.New("no default upstream servers configured") } return proxyConfig, nil @@ -250,6 +250,16 @@ func (s *Server) prepareUpstreamSettings() error { if err != nil { return fmt.Errorf("DNS: proxy.ParseUpstreamsConfig: %s", 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) + if err != nil { + return fmt.Errorf("DNS: failed to parse default upstreams: %v", err) + } + upstreamConfig.Upstreams = uc.Upstreams + } + s.conf.UpstreamConfig = &upstreamConfig return nil }