2022-11-16 10:43:16 +08:00
|
|
|
package inbound
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net"
|
|
|
|
|
2023-02-08 13:10:26 +08:00
|
|
|
"github.com/sagernet/tfo-go"
|
2022-11-16 10:43:16 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
lc = tfo.ListenConfig{
|
|
|
|
DisableTFO: true,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func SetTfo(open bool) {
|
|
|
|
lc.DisableTFO = !open
|
|
|
|
}
|
|
|
|
|
2023-08-09 17:09:03 +08:00
|
|
|
func SetMPTCP(open bool) {
|
|
|
|
setMultiPathTCP(&lc.ListenConfig, open)
|
|
|
|
}
|
|
|
|
|
2022-11-16 10:43:16 +08:00
|
|
|
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)
|
|
|
|
}
|