diff --git a/src/net/conf_test.go b/src/net/conf_test.go
index 075253c..e3dbb37 100644
--- a/src/net/conf_test.go
+++ b/src/net/conf_test.go
@@ -142,7 +142,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 4d7b2fb..fc67105 100644
--- a/src/net/dnsclient_unix.go
+++ b/src/net/dnsclient_unix.go
@@ -393,6 +393,16 @@
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
}