@@ -234,6 +234,14 @@ type SplitHTTPConfig struct {
234234 ScMinPostsIntervalMs * Int32Range `json:"scMinPostsIntervalMs"`
235235 NoSSEHeader bool `json:"noSSEHeader"`
236236 XPaddingBytes * Int32Range `json:"xPaddingBytes"`
237+ Mux SplitHTTPMux `json:"mux"`
238+ }
239+
240+ type SplitHTTPMux struct {
241+ Mode string `json:"mode"`
242+ MaxConnectionConcurrency Int32Range `json:"maxConnectionConcurrency"`
243+ MaxConnectionLifetime Int32Range `json:"maxConnectionLifetime"`
244+ MaxConnection int32 `json:"maxConnection"`
237245}
238246
239247func splithttpNewRandRangeConfig (input * Int32Range ) * splithttp.RandRangeConfig {
@@ -257,6 +265,28 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) {
257265 } else if c .Host == "" && c .Headers ["Host" ] != "" {
258266 c .Host = c .Headers ["Host" ]
259267 }
268+
269+ // Multiplexing config
270+ muxProtobuf := splithttp.Multiplexing {}
271+ switch strings .ToLower (c .Mux .Mode ) {
272+ case "disabled" , "off" , "none" :
273+ muxProtobuf .Mode = splithttp .Multiplexing_DISABLED
274+ case "prefer_reuse" , "preferreuse" , "prefer_existing" , "preferexisting" , "" : // Default: Reuse existing connections before opening new ones
275+ muxProtobuf .Mode = splithttp .Multiplexing_PREFER_EXTISTING
276+ case "prefer_new" , "prefernew" : // Open new connections until max limit, then reuse
277+ muxProtobuf .Mode = splithttp .Multiplexing_PREFER_NEW
278+ default :
279+ return nil , errors .New ("unsupported splithttp multiplexing mode: " , c .Mux .Mode )
280+ }
281+ muxProtobuf .MaxConnectionConcurrency = & splithttp.RandRangeConfig {
282+ From : c .Mux .MaxConnectionConcurrency .From ,
283+ To : c .Mux .MaxConnectionConcurrency .To ,
284+ }
285+ muxProtobuf .MaxConnectionLifetime = & splithttp.RandRangeConfig {
286+ From : c .Mux .MaxConnectionLifetime .From ,
287+ To : c .Mux .MaxConnectionLifetime .To ,
288+ }
289+ muxProtobuf .MaxConnections = c .Mux .MaxConnection
260290 config := & splithttp.Config {
261291 Path : c .Path ,
262292 Host : c .Host ,
@@ -266,6 +296,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) {
266296 ScMinPostsIntervalMs : splithttpNewRandRangeConfig (c .ScMinPostsIntervalMs ),
267297 NoSSEHeader : c .NoSSEHeader ,
268298 XPaddingBytes : splithttpNewRandRangeConfig (c .XPaddingBytes ),
299+ Mux : & muxProtobuf ,
269300 }
270301 return config , nil
271302}
0 commit comments