mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-03 02:23:59 +00:00
26 lines
443 B
Go
26 lines
443 B
Go
package inbound
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
|
|
"github.com/sagernet/tfo-go"
|
|
)
|
|
|
|
var (
|
|
lc = tfo.ListenConfig{
|
|
DisableTFO: true,
|
|
}
|
|
)
|
|
|
|
func SetTfo(open bool) {
|
|
lc.DisableTFO = !open
|
|
}
|
|
|
|
func ListenContext(ctx context.Context, network, address string) (net.Listener, error) {
|
|
return lc.Listen(ctx, network, address)
|
|
}
|
|
|
|
func Listen(network, address string) (net.Listener, error) {
|
|
return ListenContext(context.Background(), network, address)
|
|
}
|