Skip to content

Commit

Permalink
chore: disable tfo when lower than Windows 10.0.14393
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed May 12, 2024
1 parent a50339b commit 3ae4014
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion component/dialer/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func dialContext(ctx context.Context, network string, destination netip.Addr, po
if opt.mpTcp {
setMultiPathTCP(dialer)
}
if opt.tfo {
if opt.tfo && !DisableTFO {
return dialTFO(ctx, *dialer, network, address)
}
return dialer.DialContext(ctx, network, address)
Expand Down
2 changes: 2 additions & 0 deletions component/dialer/tfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/metacubex/tfo-go"
)

var DisableTFO = false

type tfoConn struct {
net.Conn
closed bool
Expand Down
11 changes: 11 additions & 0 deletions component/dialer/tfo_windows.go
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 3ae4014

Please sign in to comment.