chore: allow overriding sing-mux internal tcpTimeout value for testing

This commit is contained in:
wwqgtxx
2026-04-16 14:39:00 +08:00
parent b0b28ef002
commit d4c4b2851f
4 changed files with 9 additions and 6 deletions
+3
View File
@@ -2,6 +2,7 @@ package outbound
import (
"context"
"time"
N "github.com/metacubex/mihomo/common/net"
"github.com/metacubex/mihomo/component/proxydialer"
@@ -28,6 +29,7 @@ type SingMuxOption struct {
Padding bool `proxy:"padding,omitempty"`
Statistic bool `proxy:"statistic,omitempty"`
OnlyTcp bool `proxy:"only-tcp,omitempty"`
TCPTimeout int `proxy:"tcp-timeout,omitempty"`
BrutalOpts BrutalOption `proxy:"brutal-opts,omitempty"`
}
@@ -103,6 +105,7 @@ func NewSingMux(option SingMuxOption, proxy ProxyAdapter) (ProxyAdapter, error)
MinStreams: option.MinStreams,
MaxStreams: option.MaxStreams,
Padding: option.Padding,
TCPTimeout: time.Duration(option.TCPTimeout) * time.Second,
Brutal: mux.BrutalOptions{
Enabled: option.BrutalOpts.Enabled,
SendBPS: StringToBps(option.BrutalOpts.Up),
+1 -1
View File
@@ -29,7 +29,7 @@ require (
github.com/metacubex/randv2 v0.2.0
github.com/metacubex/restls-client-go v0.1.7
github.com/metacubex/sing v0.5.7
github.com/metacubex/sing-mux v0.3.6
github.com/metacubex/sing-mux v0.3.7
github.com/metacubex/sing-quic v0.0.0-20260414034501-3ea3410d197a
github.com/metacubex/sing-shadowsocks v0.2.12
github.com/metacubex/sing-shadowsocks2 v0.2.7
+2 -2
View File
@@ -125,8 +125,8 @@ github.com/metacubex/restls-client-go v0.1.7 h1:eCwiXCTQb5WJu9IlgYvDBA1OgrINv58d
github.com/metacubex/restls-client-go v0.1.7/go.mod h1:BN/U52vPw7j8VTSh2vleD/MnmVKCov84mS5VcjVHH4g=
github.com/metacubex/sing v0.5.7 h1:8OC+fhKFSv/l9ehEhJRaZZAOuthfZo68SteBVLe8QqM=
github.com/metacubex/sing v0.5.7/go.mod h1:ypf0mjwlZm0sKdQSY+yQvmsbWa0hNPtkeqyRMGgoN+w=
github.com/metacubex/sing-mux v0.3.6 h1:AIjxEz7pq+5DVoV9N5/xaQXz3cMSZR9PBvMRP9X3+A0=
github.com/metacubex/sing-mux v0.3.6/go.mod h1:8bT7ZKT3clRrJjYc/x5CRYibC1TX/bK73a3r3+2E+Fc=
github.com/metacubex/sing-mux v0.3.7 h1:CnsRQfxFOLNh8gZqbPVFVPNVWgq5paiLksI0tVJI5CY=
github.com/metacubex/sing-mux v0.3.7/go.mod h1:8bT7ZKT3clRrJjYc/x5CRYibC1TX/bK73a3r3+2E+Fc=
github.com/metacubex/sing-quic v0.0.0-20260414034501-3ea3410d197a h1:977o0ZYYbiQAGuOxql7Q6UN3rEy59OyAE0tELq4gZfI=
github.com/metacubex/sing-quic v0.0.0-20260414034501-3ea3410d197a/go.mod h1:6ayFGfzzBE85csgQkM3gf4neFq6s0losHlPRSxY+nuk=
github.com/metacubex/sing-shadowsocks v0.2.12 h1:Wqzo8bYXrK5aWqxu/TjlTnYZzAKtKsaFQBdr6IHFaBE=
+3 -3
View File
@@ -28,10 +28,10 @@ func testSingMux(t *testing.T, tunnel *TestTunnel, out outbound.ProxyAdapter) {
for _, protocol := range singMuxProtocolList {
protocol := protocol
t.Run(protocol, func(t *testing.T) {
t.Parallel()
singMuxOption := outbound.SingMuxOption{
Enabled: true,
Protocol: protocol,
Enabled: true,
Protocol: protocol,
TCPTimeout: 30, // set a timeout value that is slightly larger than the default
}
out, err := outbound.NewSingMux(singMuxOption, &notCloseProxyAdapter{out})
if !assert.NoError(t, err) {