Skip to content

Commit 70bc00f

Browse files
committed
useTCP: OpenBSD & FreeBSD support
1 parent 971eb36 commit 70bc00f

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

src/net/dnsconfig_unix.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,13 @@ func dnsReadConfig(filename string) *dnsConfig {
124124
// This option disables the behavior and makes glibc
125125
// perform the IPv6 and IPv4 requests sequentially."
126126
conf.singleRequest = true
127-
case s == "use-vc":
128-
// Linux glibc option:
127+
case s == "use-vc" || s == "usevc" || s == "tcp":
128+
// Linux (use-vc), FreeBSD (usevc) and OpenBSD (tcp) option:
129129
// http://man7.org/linux/man-pages/man5/resolv.conf.5.html
130130
// "Sets RES_USEVC in _res.options.
131131
// This option forces the use of TCP for DNS resolutions."
132+
// https://www.freebsd.org/cgi/man.cgi?query=resolv.conf&sektion=5&manpath=freebsd-release-ports
133+
// https://man.openbsd.org/resolv.conf.5
132134
conf.useTCP = true
133135
default:
134136
conf.unknownOpt = true

src/net/dnsconfig_unix_test.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,29 @@ var dnsReadConfigTests = []struct {
125125
},
126126
},
127127
{
128-
name: "testdata/use-vc-resolv.conf",
128+
name: "testdata/linux-use-vc-resolv.conf",
129+
want: &dnsConfig{
130+
servers: defaultNS,
131+
ndots: 1,
132+
useTCP: true,
133+
timeout: 5 * time.Second,
134+
attempts: 2,
135+
search: []string{"domain.local."},
136+
},
137+
},
138+
{
139+
name: "testdata/freebsd-usevc-resolv.conf",
140+
want: &dnsConfig{
141+
servers: defaultNS,
142+
ndots: 1,
143+
useTCP: true,
144+
timeout: 5 * time.Second,
145+
attempts: 2,
146+
search: []string{"domain.local."},
147+
},
148+
},
149+
{
150+
name: "testdata/openbsd-tcp-resolv.conf",
129151
want: &dnsConfig{
130152
servers: defaultNS,
131153
ndots: 1,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
options usevc
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
options tcp

0 commit comments

Comments
 (0)