1
0
mirror of https://github.com/golang/go synced 2024-09-29 20:24:34 -06:00

useTCP: OpenBSD & FreeBSD support

This commit is contained in:
jfbus 2019-01-08 22:41:52 +01:00
parent 971eb363f6
commit 70bc00fe41
5 changed files with 29 additions and 3 deletions

View File

@ -124,11 +124,13 @@ func dnsReadConfig(filename string) *dnsConfig {
// This option disables the behavior and makes glibc
// perform the IPv6 and IPv4 requests sequentially."
conf.singleRequest = true
case s == "use-vc":
// Linux glibc option:
case s == "use-vc" || s == "usevc" || s == "tcp":
// Linux (use-vc), FreeBSD (usevc) and OpenBSD (tcp) option:
// http://man7.org/linux/man-pages/man5/resolv.conf.5.html
// "Sets RES_USEVC in _res.options.
// This option forces the use of TCP for DNS resolutions."
// https://www.freebsd.org/cgi/man.cgi?query=resolv.conf&sektion=5&manpath=freebsd-release-ports
// https://man.openbsd.org/resolv.conf.5
conf.useTCP = true
default:
conf.unknownOpt = true

View File

@ -125,7 +125,29 @@ var dnsReadConfigTests = []struct {
},
},
{
name: "testdata/use-vc-resolv.conf",
name: "testdata/linux-use-vc-resolv.conf",
want: &dnsConfig{
servers: defaultNS,
ndots: 1,
useTCP: true,
timeout: 5 * time.Second,
attempts: 2,
search: []string{"domain.local."},
},
},
{
name: "testdata/freebsd-usevc-resolv.conf",
want: &dnsConfig{
servers: defaultNS,
ndots: 1,
useTCP: true,
timeout: 5 * time.Second,
attempts: 2,
search: []string{"domain.local."},
},
},
{
name: "testdata/openbsd-tcp-resolv.conf",
want: &dnsConfig{
servers: defaultNS,
ndots: 1,

View File

@ -0,0 +1 @@
options usevc

View File

@ -0,0 +1 @@
options tcp