forked from WhoJave/clash
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
72 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//go:build unix | ||
|
||
package inbound | ||
|
||
import ( | ||
"net" | ||
|
||
"github.com/metacubex/tfo-go" | ||
) | ||
|
||
var ( | ||
lc = tfo.ListenConfig{ | ||
DisableTFO: true, | ||
} | ||
) | ||
|
||
func SetTfo(open bool) { | ||
lc.DisableTFO = !open | ||
} | ||
|
||
func getListenConfig() *net.ListenConfig { | ||
return &lc.ListenConfig | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package inbound | ||
|
||
import ( | ||
"net" | ||
) | ||
|
||
var ( | ||
lc = net.ListenConfig{} | ||
) | ||
|
||
func SetTfo(open bool) {} | ||
|
||
func getListenConfig() *net.ListenConfig { | ||
return &lc | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//go:build unix | ||
|
||
package dialer | ||
|
||
import ( | ||
"context" | ||
"net" | ||
|
||
"github.com/metacubex/tfo-go" | ||
) | ||
|
||
const DisableTFO = false | ||
|
||
func dialTFO(ctx context.Context, netDialer net.Dialer, network, address string) (net.Conn, error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), DefaultTCPTimeout) | ||
dialer := tfo.Dialer{Dialer: netDialer, DisableTFO: false} | ||
return &tfoConn{ | ||
dialed: make(chan bool, 1), | ||
cancel: cancel, | ||
ctx: ctx, | ||
dialFn: func(ctx context.Context, earlyData []byte) (net.Conn, error) { | ||
return dialer.DialContext(ctx, network, address, earlyData) | ||
}, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package dialer | ||
|
||
import "github.com/metacubex/mihomo/constant/features" | ||
import ( | ||
"context" | ||
"net" | ||
) | ||
|
||
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 | ||
} | ||
const DisableTFO = true | ||
|
||
func dialTFO(ctx context.Context, netDialer net.Dialer, network, address string) (net.Conn, error) { | ||
return netDialer.DialContext(ctx, network, address) | ||
} |