net: treat a nil *Resolver as a zero one, as documented

Add accessors that handle nil without crashing.

Fixes #24330

Change-Id: If5fbbb6015ca8d65f620a06bad6e52de8cd896ad
Reviewed-on: https://go-review.googlesource.com/101315
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
This commit is contained in:
Brad Fitzpatrick 2018-03-19 09:16:25 +03:00
parent 5a4e09837c
commit 5c3cb64b2e
6 changed files with 37 additions and 10 deletions

View file

@ -377,7 +377,7 @@ func (r *Resolver) lookup(ctx context.Context, name string, qtype dnsmessage.Typ
if err == nil {
break
}
if nerr, ok := err.(Error); ok && nerr.Temporary() && r.StrictErrors {
if nerr, ok := err.(Error); ok && nerr.Temporary() && r.strictErrors() {
// If we hit a temporary error with StrictErrors enabled,
// stop immediately instead of trying more names.
break
@ -565,7 +565,7 @@ func (r *Resolver) goLookupIPCNAMEOrder(ctx context.Context, name string, order
for range qtypes {
racer := <-lane
if racer.error != nil {
if nerr, ok := racer.error.(Error); ok && nerr.Temporary() && r.StrictErrors {
if nerr, ok := racer.error.(Error); ok && nerr.Temporary() && r.strictErrors() {
// This error will abort the nameList loop.
hitStrictError = true
lastErr = racer.error