chore: force to disable mptcp for tproxy

This commit is contained in:
wwqgtxx
2025-12-31 08:43:23 +08:00
parent eb30d3f331
commit 1f8bee9710
9 changed files with 58 additions and 61 deletions

View File

@@ -1,10 +1,12 @@
package tproxy
import (
"context"
"net"
"github.com/metacubex/mihomo/adapter/inbound"
"github.com/metacubex/mihomo/component/keepalive"
"github.com/metacubex/mihomo/component/mptcp"
C "github.com/metacubex/mihomo/constant"
"github.com/metacubex/mihomo/transport/socks5"
)
@@ -46,10 +48,11 @@ func New(addr string, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener
inbound.WithSpecialRules(""),
}
}
//TODO: When we upgrade the major version of go.mod to 1.24 or higher, disable mptcp for tproxy.
// Golang will then enable mptcp support for listeners by default.
// This can cause tproxy to malfunction on certain Linux kernel versions.
l, err := net.Listen("tcp", addr)
// Golang will then enable mptcp support for listeners by default when the major version of go.mod is 1.24 or higher.
// This can cause tproxy to malfunction on certain Linux kernel versions, so we force to disable mptcp for tproxy.
lc := net.ListenConfig{}
mptcp.SetNetListenConfig(&lc, false)
l, err := lc.Listen(context.Background(), "tcp", addr)
if err != nil {
return nil, err
}