diff --git a/src/net/dnsconfig_unix.go b/src/net/dnsconfig_unix.go index e72bca6ff1..877e77c049 100644 --- a/src/net/dnsconfig_unix.go +++ b/src/net/dnsconfig_unix.go @@ -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 diff --git a/src/net/dnsconfig_unix_test.go b/src/net/dnsconfig_unix_test.go index e6ba5fe4a3..42880123c5 100644 --- a/src/net/dnsconfig_unix_test.go +++ b/src/net/dnsconfig_unix_test.go @@ -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, diff --git a/src/net/testdata/freebsd-usevc-resolv.conf b/src/net/testdata/freebsd-usevc-resolv.conf new file mode 100644 index 0000000000..4afb281c5b --- /dev/null +++ b/src/net/testdata/freebsd-usevc-resolv.conf @@ -0,0 +1 @@ +options usevc \ No newline at end of file diff --git a/src/net/testdata/use-vc-resolv.conf b/src/net/testdata/linux-use-vc-resolv.conf similarity index 100% rename from src/net/testdata/use-vc-resolv.conf rename to src/net/testdata/linux-use-vc-resolv.conf diff --git a/src/net/testdata/openbsd-tcp-resolv.conf b/src/net/testdata/openbsd-tcp-resolv.conf new file mode 100644 index 0000000000..7929e50e8d --- /dev/null +++ b/src/net/testdata/openbsd-tcp-resolv.conf @@ -0,0 +1 @@ +options tcp \ No newline at end of file