summaryrefslogtreecommitdiff
path: root/src/net/dnsconfig_unix.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2022-05-28 14:06:43 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2022-05-30 21:23:29 +0000
commitaf88fb6502ceee973aaa118471c9d953a10a68e5 (patch)
tree47311985ce8c9f402fab2c2c903cf66fd1d26cf0 /src/net/dnsconfig_unix.go
parenta21cf916f418d0d48f46d8f256c5994a80558a94 (diff)
downloadgo-git-af88fb6502ceee973aaa118471c9d953a10a68e5.tar.gz
net: permit use of Resolver.PreferGo, netgo on Windows and Plan 9
This reverts commit CL 401754 (440c9312c8) which reverted CL 400654, thus reapplying CL 400654, re-adding the func init() { netGo = true } to cgo_stub.go CL 400654 had originally removed (mistakenly during development?) that had broken the darwin nocgo builder. Fixes #33097 Change-Id: I90f59746d2ceb6b5d2bd832c9fc90068f8ff7417 Reviewed-on: https://go-review.googlesource.com/c/go/+/409234 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'src/net/dnsconfig_unix.go')
-rw-r--r--src/net/dnsconfig_unix.go36
1 files changed, 1 insertions, 35 deletions
diff --git a/src/net/dnsconfig_unix.go b/src/net/dnsconfig_unix.go
index 7552bc51e6..94cd09ec71 100644
--- a/src/net/dnsconfig_unix.go
+++ b/src/net/dnsconfig_unix.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build unix
+//go:build !js && !windows
// Read system DNS config from /etc/resolv.conf
@@ -10,32 +10,9 @@ package net
import (
"internal/bytealg"
- "os"
- "sync/atomic"
"time"
)
-var (
- defaultNS = []string{"127.0.0.1:53", "[::1]:53"}
- getHostname = os.Hostname // variable for testing
-)
-
-type dnsConfig struct {
- servers []string // server addresses (in host:port form) to use
- search []string // rooted suffixes to append to local name
- ndots int // number of dots in name to trigger absolute lookup
- timeout time.Duration // wait before giving up on a query, including retries
- attempts int // lost packets before giving up on server
- rotate bool // round robin among servers
- unknownOpt bool // anything unknown was encountered
- lookup []string // OpenBSD top-level database "lookup" order
- err error // any error that occurs during open of resolv.conf
- mtime time.Time // time of resolv.conf modification
- soffset uint32 // used by serverOffset
- singleRequest bool // use sequential A and AAAA queries instead of parallel queries
- useTCP bool // force usage of TCP for DNS resolutions
-}
-
// See resolv.conf(5) on a Linux machine.
func dnsReadConfig(filename string) *dnsConfig {
conf := &dnsConfig{
@@ -156,17 +133,6 @@ func dnsReadConfig(filename string) *dnsConfig {
return conf
}
-// serverOffset returns an offset that can be used to determine
-// indices of servers in c.servers when making queries.
-// When the rotate option is enabled, this offset increases.
-// Otherwise it is always 0.
-func (c *dnsConfig) serverOffset() uint32 {
- if c.rotate {
- return atomic.AddUint32(&c.soffset, 1) - 1 // return 0 to start
- }
- return 0
-}
-
func dnsDefaultSearch() []string {
hn, err := getHostname()
if err != nil {