mirror of
https://github.com/golang/go
synced 2024-11-18 13:04:46 -07:00
net: simplify probeIPv6Stack
R=golang-dev, dave CC=golang-dev https://golang.org/cl/11807043
This commit is contained in:
parent
085159da26
commit
c0a4ce52c6
@ -28,7 +28,7 @@ import (
|
||||
// boolean value is true, kernel supports IPv6 IPv4-mapping.
|
||||
func probeIPv6Stack() (supportsIPv6, supportsIPv4map bool) {
|
||||
var probes = []struct {
|
||||
la TCPAddr
|
||||
laddr TCPAddr
|
||||
ok bool
|
||||
}{
|
||||
// IPv6 communication capability
|
||||
@ -44,12 +44,11 @@ func probeIPv6Stack() (supportsIPv6, supportsIPv4map bool) {
|
||||
}
|
||||
defer closesocket(s)
|
||||
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 {
|
||||
continue
|
||||
}
|
||||
err = syscall.Bind(s, sa)
|
||||
if err != nil {
|
||||
if err := syscall.Bind(s, sa); err != nil {
|
||||
continue
|
||||
}
|
||||
probes[i].ok = true
|
||||
|
Loading…
Reference in New Issue
Block a user