Add maxReuseTimes

This commit is contained in:
Fangliding
2024-12-31 18:38:03 +08:00
parent dee64ef240
commit a0bf239fc1
7 changed files with 34 additions and 11 deletions
+8 -2
View File
@@ -121,6 +121,12 @@ func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (outbou
if h.senderSettings != nil && h.senderSettings.MultiplexSettings != nil {
if config := h.senderSettings.MultiplexSettings; config.Enabled {
// MaxReuseTimes use 60000 as default, and it also means the upper limit of MaxReuseTimes
// In mux cool spec, connection ID is 2 bytes, so physical limit is 65535, bu we reserve some IDs for future use
MaxReuseTimes := uint32(60000)
if config.MaxReuseTimes != 0 && config.MaxReuseTimes < 60000 {
MaxReuseTimes = uint32(config.MaxReuseTimes)
}
if config.Concurrency < 0 {
h.mux = &mux.ClientManager{Enabled: false}
}
@@ -136,7 +142,7 @@ func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (outbou
Dialer: h,
Strategy: mux.ClientStrategy{
MaxConcurrency: uint32(config.Concurrency),
MaxConnection: 128,
MaxReuseTimes: MaxReuseTimes,
},
},
},
@@ -157,7 +163,7 @@ func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (outbou
Dialer: h,
Strategy: mux.ClientStrategy{
MaxConcurrency: uint32(config.XudpConcurrency),
MaxConnection: 128,
MaxReuseTimes: 128,
},
},
},