src/net/conf_test.go | 14 +++++++------- src/net/dnsclient_unix.go | 10 ++++++++++ diff --git a/src/net/conf_test.go b/src/net/conf_test.go index 075253cbc13dd9055368adac006f493e4a5945a7..e3dbb37f19e6c13398df469472ebd7f834706788 100644 --- a/src/net/conf_test.go +++ b/src/net/conf_test.go @@ -142,7 +142,7 @@ name: "openbsd_lookup_bind_file", c: &conf{ goos: "openbsd", }, - resolv: &dnsConfig{lookup: []string{"bind", "file"}}, + resolv: &dnsConfig{servers: defaultNS, lookup: []string{"bind", "file"}}, hostTests: []nssHostTest{ {"google.com", "myhostname", hostLookupDNSFiles}, {"foo.local", "myhostname", hostLookupDNSFiles}, @@ -153,7 +153,7 @@ name: "openbsd_lookup_file_bind", c: &conf{ goos: "openbsd", }, - resolv: &dnsConfig{lookup: []string{"file", "bind"}}, + resolv: &dnsConfig{servers: defaultNS, lookup: []string{"file", "bind"}}, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupFilesDNS}}, }, { @@ -161,7 +161,7 @@ name: "openbsd_lookup_bind", c: &conf{ goos: "openbsd", }, - resolv: &dnsConfig{lookup: []string{"bind"}}, + resolv: &dnsConfig{servers: defaultNS, lookup: []string{"bind"}}, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupDNS}}, }, { @@ -169,7 +169,7 @@ name: "openbsd_lookup_file", c: &conf{ goos: "openbsd", }, - resolv: &dnsConfig{lookup: []string{"file"}}, + resolv: &dnsConfig{servers: defaultNS, lookup: []string{"file"}}, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupFiles}}, }, { @@ -177,7 +177,7 @@ name: "openbsd_lookup_yp", c: &conf{ goos: "openbsd", }, - resolv: &dnsConfig{lookup: []string{"file", "bind", "yp"}}, + resolv: &dnsConfig{servers: defaultNS, lookup: []string{"file", "bind", "yp"}}, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupCgo}}, }, { @@ -185,7 +185,7 @@ name: "openbsd_lookup_two", c: &conf{ goos: "openbsd", }, - resolv: &dnsConfig{lookup: []string{"file", "foo"}}, + resolv: &dnsConfig{servers: defaultNS, lookup: []string{"file", "foo"}}, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupCgo}}, }, { @@ -193,7 +193,7 @@ name: "openbsd_lookup_empty", c: &conf{ goos: "openbsd", }, - resolv: &dnsConfig{lookup: nil}, + resolv: &dnsConfig{servers: defaultNS, lookup: nil}, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupDNSFiles}}, }, { diff --git a/src/net/dnsclient_unix.go b/src/net/dnsclient_unix.go index 4d7b2fb5ea4de27d9b4a88f01cec4c7bf57026f1..fc671053f559a87c455c70186889657a75847ae5 100644 --- a/src/net/dnsclient_unix.go +++ b/src/net/dnsclient_unix.go @@ -393,6 +393,16 @@ func (conf *resolverConfig) tryUpdate(name string) { conf.initOnce.Do(conf.init) dc := conf.dnsConfig.Load() + + // Currently we should never have a config that does not have any + // available servers to query, since in such cases the servers field + // is set to [defaultNS], see dnsReadConfig. + // This assertion main purpose is for testing, such that we never set + // the mocked dnsConfig in such way. + if len(dc.servers) == 0 { + panic("unreachable") + } + if dc.noReload { return }