diff options
author | Ondřej Surý <ondrej@sury.org> | 2012-03-26 16:50:58 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2012-03-26 16:50:58 +0200 |
commit | 519725bb3c075ee2462c929f5997cb068e18466a (patch) | |
tree | 5b162e8488ad147a645048c073577821b4a2bee9 /src/pkg/net/sockopt_linux.go | |
parent | 842623c5dd2819d980ca9c58048d6bc6ed82475f (diff) | |
download | golang-upstream-weekly/2012.03.22.tar.gz |
Imported Upstream version 2012.03.22upstream-weekly/2012.03.22
Diffstat (limited to 'src/pkg/net/sockopt_linux.go')
-rw-r--r-- | src/pkg/net/sockopt_linux.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/pkg/net/sockopt_linux.go b/src/pkg/net/sockopt_linux.go index 7509c29ee..0f47538c5 100644 --- a/src/pkg/net/sockopt_linux.go +++ b/src/pkg/net/sockopt_linux.go @@ -11,12 +11,17 @@ import ( "syscall" ) -func setDefaultSockopts(s, f, t int) error { +func setDefaultSockopts(s, f, t int, ipv6only bool) error { switch f { case syscall.AF_INET6: - // Allow both IP versions even if the OS default is otherwise. - // Note that some operating systems never admit this option. - syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, 0) + if ipv6only { + syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, 1) + } else { + // Allow both IP versions even if the OS default + // is otherwise. Note that some operating systems + // never admit this option. + syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, 0) + } } // Allow broadcast. err := syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1) |