Skip to content

Commit

Permalink
dnsforward: imp code
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Jan 11, 2024
1 parent 6f5c271 commit 0e925c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions internal/dnsforward/http.go
Expand Up @@ -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 == "" {
Expand All @@ -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)
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/dnsforward/http_test.go
Expand Up @@ -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`,
Expand Down

0 comments on commit 0e925c1

Please sign in to comment.