chore: disable tfo when lower than Windows 10.0.14393

This commit is contained in:
wwqgtxx 2024-05-12 20:44:12 +08:00
parent a50339bd5f
commit 3ae4014b39
3 changed files with 14 additions and 1 deletions

View File

@ -164,7 +164,7 @@ func dialContext(ctx context.Context, network string, destination netip.Addr, po
if opt.mpTcp { if opt.mpTcp {
setMultiPathTCP(dialer) setMultiPathTCP(dialer)
} }
if opt.tfo { if opt.tfo && !DisableTFO {
return dialTFO(ctx, *dialer, network, address) return dialTFO(ctx, *dialer, network, address)
} }
return dialer.DialContext(ctx, network, address) return dialer.DialContext(ctx, network, address)

View File

@ -9,6 +9,8 @@ import (
"github.com/metacubex/tfo-go" "github.com/metacubex/tfo-go"
) )
var DisableTFO = false
type tfoConn struct { type tfoConn struct {
net.Conn net.Conn
closed bool closed bool

View File

@ -0,0 +1,11 @@
package dialer
import "github.com/metacubex/mihomo/constant/features"
func init() {
// According to MSDN, this option is available since Windows 10, 1607
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms738596(v=vs.85).aspx
if features.WindowsMajorVersion < 10 || (features.WindowsMajorVersion == 10 && features.WindowsBuildNumber < 14393) {
DisableTFO = true
}
}