mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 07:43:13 +08:00
chore: swtich RtlGetNtVersionNumbers
to RtlGetVersion
https://go-review.googlesource.com/c/go/+/571015
This commit is contained in:
parent
7df1c26942
commit
a50339bd5f
@ -1,15 +1,14 @@
|
|||||||
package ca
|
package ca
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"golang.org/x/sys/windows"
|
"github.com/metacubex/mihomo/constant/features"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
majorVersion, _, _ := windows.RtlGetNtVersionNumbers()
|
|
||||||
// crypto/x509: certificate validation in Windows fails to validate IP in SAN
|
// crypto/x509: certificate validation in Windows fails to validate IP in SAN
|
||||||
// https://github.com/golang/go/issues/37176
|
// https://github.com/golang/go/issues/37176
|
||||||
// As far as I can tell this is still the case on most older versions of Windows (but seems to be fixed in 10)
|
// As far as I can tell this is still the case on most older versions of Windows (but seems to be fixed in 10)
|
||||||
if majorVersion < 10 && len(_CaCertificates) > 0 {
|
if features.WindowsMajorVersion < 10 && len(_CaCertificates) > 0 {
|
||||||
DisableSystemCa = true
|
DisableSystemCa = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
constant/features/version.go
Normal file
5
constant/features/version.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package features
|
||||||
|
|
||||||
|
var WindowsMajorVersion uint32
|
||||||
|
var WindowsMinorVersion uint32
|
||||||
|
var WindowsBuildNumber uint32
|
10
constant/features/version_windows.go
Normal file
10
constant/features/version_windows.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package features
|
||||||
|
|
||||||
|
import "golang.org/x/sys/windows"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
version := windows.RtlGetVersion()
|
||||||
|
WindowsMajorVersion = version.MajorVersion
|
||||||
|
WindowsMinorVersion = version.MinorVersion
|
||||||
|
WindowsBuildNumber = version.MinorVersion
|
||||||
|
}
|
@ -3,11 +3,10 @@ package sing_tun
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/metacubex/mihomo/constant/features"
|
||||||
"github.com/metacubex/mihomo/log"
|
"github.com/metacubex/mihomo/log"
|
||||||
|
|
||||||
tun "github.com/metacubex/sing-tun"
|
tun "github.com/metacubex/sing-tun"
|
||||||
|
|
||||||
"golang.org/x/sys/windows"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func tunNew(options tun.Options) (tunIf tun.Tun, err error) {
|
func tunNew(options tun.Options) (tunIf tun.Tun, err error) {
|
||||||
@ -30,8 +29,7 @@ func tunNew(options tun.Options) (tunIf tun.Tun, err error) {
|
|||||||
func init() {
|
func init() {
|
||||||
tun.TunnelType = InterfaceName
|
tun.TunnelType = InterfaceName
|
||||||
|
|
||||||
majorVersion, _, _ := windows.RtlGetNtVersionNumbers()
|
if features.WindowsMajorVersion < 10 {
|
||||||
if majorVersion < 10 {
|
|
||||||
// to resolve "bind: The requested address is not valid in its context"
|
// to resolve "bind: The requested address is not valid in its context"
|
||||||
EnforceBindInterface = true
|
EnforceBindInterface = true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user