1
0
mirror of https://github.com/golang/go synced 2024-11-05 16:16:11 -07:00

net: simplify probeIPv6Stack

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/11807043
This commit is contained in:
Mikio Hara 2013-07-25 19:29:20 +09:00
parent 085159da26
commit c0a4ce52c6

View File

@ -28,7 +28,7 @@ import (
// boolean value is true, kernel supports IPv6 IPv4-mapping. // boolean value is true, kernel supports IPv6 IPv4-mapping.
func probeIPv6Stack() (supportsIPv6, supportsIPv4map bool) { func probeIPv6Stack() (supportsIPv6, supportsIPv4map bool) {
var probes = []struct { var probes = []struct {
la TCPAddr laddr TCPAddr
ok bool ok bool
}{ }{
// IPv6 communication capability // IPv6 communication capability
@ -44,12 +44,11 @@ func probeIPv6Stack() (supportsIPv6, supportsIPv4map bool) {
} }
defer closesocket(s) defer closesocket(s)
syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, 0) syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, 0)
sa, err := probes[i].la.toAddr().sockaddr(syscall.AF_INET6) sa, err := probes[i].laddr.sockaddr(syscall.AF_INET6)
if err != nil { if err != nil {
continue continue
} }
err = syscall.Bind(s, sa) if err := syscall.Bind(s, sa); err != nil {
if err != nil {
continue continue
} }
probes[i].ok = true probes[i].ok = true