From 0e925c1fcfb5ea4b712360721b62ecef1c8355d8 Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Thu, 11 Jan 2024 14:24:47 +0300 Subject: [PATCH] dnsforward: imp code --- internal/dnsforward/http.go | 6 ++++-- internal/dnsforward/http_test.go | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/dnsforward/http.go b/internal/dnsforward/http.go index 06f9009e3ce..d3d352dfc4c 100644 --- a/internal/dnsforward/http.go +++ b/internal/dnsforward/http.go @@ -267,7 +267,7 @@ func (req *jsonDNSConfig) checkBootstrap() (err error) { } var b string - defer func() { err = errors.Annotate(err, "checking bootstrap %s: invalid address: %w", b) }() + defer func() { err = errors.Annotate(err, "checking bootstrap %s: %w", b) }() for _, b = range *req.Bootstraps { if b == "" { @@ -278,7 +278,9 @@ func (req *jsonDNSConfig) checkBootstrap() (err error) { if resolver, err = upstream.NewUpstreamResolver(b, nil); err != nil { // Don't wrap the error because it's informative enough as is. return err - } else if err = resolver.Close(); err != nil { + } + + if err = resolver.Close(); err != nil { return fmt.Errorf("closing %s: %w", b, err) } } diff --git a/internal/dnsforward/http_test.go b/internal/dnsforward/http_test.go index 0393ee30cb5..2e28039f514 100644 --- a/internal/dnsforward/http_test.go +++ b/internal/dnsforward/http_test.go @@ -227,8 +227,8 @@ func TestDNSForwardHTTP_handleSetConfig(t *testing.T) { `upstream servers: validating upstream "!!!": not an ip:port`, }, { name: "bootstraps_bad", - wantSet: `validating dns config: checking bootstrap a: invalid address: not a bootstrap: ` + - `ParseAddr("a"): unable to parse IP`, + wantSet: `validating dns config: checking bootstrap a: not a bootstrap: ParseAddr("a"): ` + + `unable to parse IP`, }, { name: "cache_bad_ttl", wantSet: `validating dns config: cache_ttl_min must be less than or equal to cache_ttl_max`,