[go] Always set the servers field to defaultNS

1 view
Skip to first unread message

Mateusz Poliwczak (Gerrit)

unread,
5:06 AM (10 hours ago) 5:06 AM
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Mateusz Poliwczak has uploaded the change for review

Commit message

Always set the servers field to defaultNS

When the field is parsed from a file, it would never
have len(servers) == 0, lets enforce that and update
test cases where we had it wrong.
Change-Id: I7fa6ebcf63b9fe20fbbf791113ca948d6a6a6964

Change diff

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
}

Change information

Files:
  • M src/net/conf_test.go
  • M src/net/dnsclient_unix.go
Change size: S
Delta: 2 files changed, 17 insertions(+), 7 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I7fa6ebcf63b9fe20fbbf791113ca948d6a6a6964
Gerrit-Change-Number: 743020
Gerrit-PatchSet: 1
Gerrit-Owner: Mateusz Poliwczak <mpoliw...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Mateusz Poliwczak (Gerrit)

unread,
5:06 AM (10 hours ago) 5:06 AM
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Mateusz Poliwczak uploaded new patchset

Mateusz Poliwczak uploaded patch set #2 to this change.
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I7fa6ebcf63b9fe20fbbf791113ca948d6a6a6964
Gerrit-Change-Number: 743020
Gerrit-PatchSet: 2
Gerrit-Owner: Mateusz Poliwczak <mpoliw...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Mateusz Poliwczak (Gerrit)

unread,
5:06 AM (10 hours ago) 5:06 AM
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Mateusz Poliwczak voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I7fa6ebcf63b9fe20fbbf791113ca948d6a6a6964
Gerrit-Change-Number: 743020
Gerrit-PatchSet: 2
Gerrit-Owner: Mateusz Poliwczak <mpoliw...@gmail.com>
Gerrit-Reviewer: Mateusz Poliwczak <mpoliw...@gmail.com>
Gerrit-Comment-Date: Sat, 07 Feb 2026 10:06:44 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Sean Liao (Gerrit)

unread,
7:55 AM (7 hours ago) 7:55 AM
to Mateusz Poliwczak, goph...@pubsubhelper.golang.org, Go LUCI, Ian Lance Taylor, Damien Neil, golang-co...@googlegroups.com
Attention needed from Damien Neil, Ian Lance Taylor and Mateusz Poliwczak

Sean Liao voted Code-Review+2

Code-Review+2
Open in Gerrit

Related details

Attention is currently required from:
  • Damien Neil
  • Ian Lance Taylor
  • Mateusz Poliwczak
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I7fa6ebcf63b9fe20fbbf791113ca948d6a6a6964
Gerrit-Change-Number: 743020
Gerrit-PatchSet: 2
Gerrit-Owner: Mateusz Poliwczak <mpoliw...@gmail.com>
Gerrit-Reviewer: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Mateusz Poliwczak <mpoliw...@gmail.com>
Gerrit-Reviewer: Sean Liao <se...@liao.dev>
Gerrit-Attention: Mateusz Poliwczak <mpoliw...@gmail.com>
Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Damien Neil <dn...@google.com>
Gerrit-Comment-Date: Sat, 07 Feb 2026 12:55:37 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages