mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 19:56:51 +08:00
d3fea909e9
Golang officially decided not to open `internal/poll.execIO` to third-party libraries after 1.23 was released, so we can only choose to remove tfo support on the Windows platform.
26 lines
592 B
Go
26 lines
592 B
Go
//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
|
|
}
|