package windows
import (
- "sync"
"syscall"
_ "unsafe"
)
Rtt uint16
MaxSynRetransmissions uint8
}
-
-var Support_TCP_INITIAL_RTO_NO_SYN_RETRANSMISSIONS = sync.OnceValue(func() bool {
- var maj, min, build uint32
- rtlGetNtVersionNumbers(&maj, &min, &build)
- return maj >= 10 && build&0xffff >= 16299
-})
-
-//go:linkname rtlGetNtVersionNumbers syscall.rtlGetNtVersionNumbers
-//go:noescape
-func rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32)
package windows
-import "sync"
+import (
+ "sync"
+ _ "unsafe" // for linkname
+)
// Version retrieves the major, minor, and build version numbers
// of the current Windows OS from the RtlGetNtVersionNumbers API
return
}
+//go:linkname rtlGetNtVersionNumbers syscall.rtlGetNtVersionNumbers
+//go:noescape
+func rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32)
+
// SupportFullTCPKeepAlive indicates whether the current Windows version
// supports the full TCP keep-alive configurations, the minimal requirement
// is Windows 10, version 1709.
major, _, build := Version()
return major >= 10 && build >= 16299
})
+
+// SupportTCPInitialRTONoSYNRetransmissions indicates whether the current
+// Windows version supports the TCP_INITIAL_RTO_NO_SYN_RETRANSMISSIONS, the
+// minimal requirement is Windows 10.0.16299.
+var SupportTCPInitialRTONoSYNRetransmissions = sync.OnceValue(func() bool {
+ major, _, build := Version()
+ return major >= 10 && build >= 16299
+})
+
+// SupportUnixSocket indicates whether the current Windows version supports
+// Unix Domain Sockets, the minimal requirement is Windows 10, build 17063.
+var SupportUnixSocket = sync.OnceValue(func() bool {
+ major, _, build := Version()
+ return major >= 10 && build >= 17063
+})
Rtt: windows.TCP_INITIAL_RTO_UNSPECIFIED_RTT, // use the default or overridden by the Administrator
MaxSynRetransmissions: 1, // minimum possible value before Windows 10.0.16299
}
- if windows.Support_TCP_INITIAL_RTO_NO_SYN_RETRANSMISSIONS() {
+ if windows.SupportTCPInitialRTONoSYNRetransmissions() {
// In Windows 10.0.16299 TCP_INITIAL_RTO_NO_SYN_RETRANSMISSIONS makes ConnectEx() fails instantly.
params.MaxSynRetransmissions = windows.TCP_INITIAL_RTO_NO_SYN_RETRANSMISSIONS
}
package net
import (
- "internal/syscall/windows/registry"
+ "internal/syscall/windows"
"os"
"reflect"
"runtime"
- "strconv"
"testing"
)
-func isBuild17063() bool {
- k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.READ)
- if err != nil {
- return false
- }
- defer k.Close()
-
- s, _, err := k.GetStringValue("CurrentBuild")
- if err != nil {
- return false
- }
- ver, err := strconv.Atoi(s)
- if err != nil {
- return false
- }
- return ver >= 17063
-}
-
func skipIfUnixSocketNotSupported(t *testing.T) {
- // TODO: the isBuild17063 check should be enough, investigate why 386 and arm
+ // TODO: the windows.SupportUnixSocket check should be enough, investigate why 386 and arm
// can't run these tests on newer Windows.
switch runtime.GOARCH {
case "386":
case "arm":
t.Skip("not supported on windows/arm, see golang.org/issue/28061")
}
- if !isBuild17063() {
+ if !windows.SupportUnixSocket() {
t.Skip("unix test")
}
}