diff --git a/adapter/inbound/listen.go b/adapter/inbound/listen.go index fa82db92..8b7b5fb2 100644 --- a/adapter/inbound/listen.go +++ b/adapter/inbound/listen.go @@ -17,6 +17,10 @@ func SetTfo(open bool) { lc.DisableTFO = !open } +func SetMPTCP(open bool) { + setMultiPathTCP(&lc.ListenConfig, open) +} + func ListenContext(ctx context.Context, network, address string) (net.Listener, error) { return lc.Listen(ctx, network, address) } diff --git a/adapter/inbound/mptcp_go120.go b/adapter/inbound/mptcp_go120.go new file mode 100644 index 00000000..f9b22533 --- /dev/null +++ b/adapter/inbound/mptcp_go120.go @@ -0,0 +1,10 @@ +//go:build !go1.21 + +package inbound + +import "net" + +const multipathTCPAvailable = false + +func setMultiPathTCP(listenConfig *net.ListenConfig, open bool) { +} diff --git a/adapter/inbound/mptcp_go121.go b/adapter/inbound/mptcp_go121.go new file mode 100644 index 00000000..6b35d1a8 --- /dev/null +++ b/adapter/inbound/mptcp_go121.go @@ -0,0 +1,11 @@ +//go:build go1.21 + +package inbound + +import "net" + +const multipathTCPAvailable = true + +func setMultiPathTCP(listenConfig *net.ListenConfig, open bool) { + listenConfig.SetMultipathTCP(open) +} diff --git a/config/config.go b/config/config.go index ba6271ed..cb30999b 100644 --- a/config/config.go +++ b/config/config.go @@ -76,6 +76,7 @@ type Inbound struct { AllowLan bool `json:"allow-lan"` BindAddress string `json:"bind-address"` InboundTfo bool `json:"inbound-tfo"` + InboundMPTCP bool `json:"inbound-mptcp"` } // Controller config @@ -243,6 +244,7 @@ type RawConfig struct { ShadowSocksConfig string `yaml:"ss-config"` VmessConfig string `yaml:"vmess-config"` InboundTfo bool `yaml:"inbound-tfo"` + InboundMPTCP bool `yaml:"inbound-mptcp"` Authentication []string `yaml:"authentication"` AllowLan bool `yaml:"allow-lan"` BindAddress string `yaml:"bind-address"` @@ -557,6 +559,7 @@ func parseGeneral(cfg *RawConfig) (*General, error) { AllowLan: cfg.AllowLan, BindAddress: cfg.BindAddress, InboundTfo: cfg.InboundTfo, + InboundMPTCP: cfg.InboundMPTCP, }, Controller: Controller{ ExternalController: cfg.ExternalController, diff --git a/hub/executor/executor.go b/hub/executor/executor.go index 724150e7..f4cda47a 100644 --- a/hub/executor/executor.go +++ b/hub/executor/executor.go @@ -360,6 +360,7 @@ func updateGeneral(general *config.General) { } inbound.SetTfo(general.InboundTfo) + inbound.SetMPTCP(general.InboundMPTCP) adapter.UnifiedDelay.Store(general.UnifiedDelay)