Skip to content

Commit

Permalink
useTCP: OpenBSD & FreeBSD support
Browse files Browse the repository at this point in the history
  • Loading branch information
jfbus committed Jan 8, 2019
1 parent 8197318 commit 2b9348a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/net/dnsconfig_unix.go
Expand Up @@ -116,11 +116,13 @@ func dnsReadConfig(filename string) *dnsConfig {
conf.attempts = n
case s == "rotate":
conf.rotate = 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
Expand Down
24 changes: 23 additions & 1 deletion src/net/dnsconfig_unix_test.go
Expand Up @@ -103,7 +103,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,
Expand Down
1 change: 1 addition & 0 deletions src/net/testdata/freebsd-usevc-resolv.conf
@@ -0,0 +1 @@
options usevc
File renamed without changes.
1 change: 1 addition & 0 deletions src/net/testdata/openbsd-tcp-resolv.conf
@@ -0,0 +1 @@
options tcp

0 comments on commit 2b9348a

Please sign in to comment.