blob: 645b267b78090835050a56c68e768759239b0f5f [file] [log] [blame]
Ian Lance Taylor22b955c2016-07-22 18:15:38 +00001// Copyright 2015 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.
4
Ian Lance Taylorc5b21c32021-07-30 14:28:58 -07005//go:build !js && !plan9 && !windows
Ian Lance Taylor5a8ea162020-01-02 15:05:27 -08006// +build !js,!plan9,!windows
Ian Lance Taylor22b955c2016-07-22 18:15:38 +00007
8package net
9
10// forceGoDNS forces the resolver configuration to use the pure Go resolver
11// and returns a fixup function to restore the old settings.
12func forceGoDNS() func() {
13 c := systemConf()
14 oldGo := c.netGo
15 oldCgo := c.netCgo
16 fixup := func() {
17 c.netGo = oldGo
18 c.netCgo = oldCgo
19 }
20 c.netGo = true
21 c.netCgo = false
22 return fixup
23}
24
25// forceCgoDNS forces the resolver configuration to use the cgo resolver
26// and returns a fixup function to restore the old settings.
27// (On non-Unix systems forceCgoDNS returns nil.)
28func forceCgoDNS() func() {
29 c := systemConf()
30 oldGo := c.netGo
31 oldCgo := c.netCgo
32 fixup := func() {
33 c.netGo = oldGo
34 c.netCgo = oldCgo
35 }
36 c.netGo = false
37 c.netCgo = true
38 return fixup
39}