1 // Copyright 2022 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
14 defaultNS = []string{"127.0.0.1:53", "[::1]:53"}
15 getHostname = os.Hostname // variable for testing
18 type dnsConfig struct {
19 servers []string // server addresses (in host:port form) to use
20 search []string // rooted suffixes to append to local name
21 ndots int // number of dots in name to trigger absolute lookup
22 timeout time.Duration // wait before giving up on a query, including retries
23 attempts int // lost packets before giving up on server
24 rotate bool // round robin among servers
25 unknownOpt bool // anything unknown was encountered
26 lookup []string // OpenBSD top-level database "lookup" order
27 err error // any error that occurs during open of resolv.conf
28 mtime time.Time // time of resolv.conf modification
29 soffset uint32 // used by serverOffset
30 singleRequest bool // use sequential A and AAAA queries instead of parallel queries
31 useTCP bool // force usage of TCP for DNS resolutions
32 trustAD bool // add AD flag to queries
33 noReload bool // do not check for config file updates
36 // serverOffset returns an offset that can be used to determine
37 // indices of servers in c.servers when making queries.
38 // When the rotate option is enabled, this offset increases.
39 // Otherwise it is always 0.
40 func (c *dnsConfig) serverOffset() uint32 {
42 return atomic.AddUint32(&c.soffset, 1) - 1 // return 0 to start