mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 17:38:41 +00:00
SplitHTTP client: Add xmux (multiplex controller) for H3 & H2 (#3613)
https://github.com/XTLS/Xray-core/pull/3613#issuecomment-2351954957 Closes https://github.com/XTLS/Xray-core/issues/3560#issuecomment-2247495778 --------- Co-authored-by: mmmray <142015632+mmmray@users.noreply.github.com>
This commit is contained in:
parent
a931507dd6
commit
b1c6471eeb
9 changed files with 475 additions and 64 deletions
|
@ -231,6 +231,14 @@ type SplitHTTPConfig struct {
|
|||
ScMinPostsIntervalMs *Int32Range `json:"scMinPostsIntervalMs"`
|
||||
NoSSEHeader bool `json:"noSSEHeader"`
|
||||
XPaddingBytes *Int32Range `json:"xPaddingBytes"`
|
||||
Xmux Xmux `json:"xmux"`
|
||||
}
|
||||
|
||||
type Xmux struct {
|
||||
maxConnections *Int32Range `json:"maxConnections"`
|
||||
maxConcurrency *Int32Range `json:"maxConcurrency"`
|
||||
cMaxReuseTimes *Int32Range `json:"cMaxReuseTimes"`
|
||||
cMaxLifetimeMs *Int32Range `json:"cMaxLifetimeMs"`
|
||||
}
|
||||
|
||||
func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig {
|
||||
|
@ -254,6 +262,19 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) {
|
|||
} else if c.Host == "" && c.Headers["Host"] != "" {
|
||||
c.Host = c.Headers["Host"]
|
||||
}
|
||||
|
||||
if c.Xmux.maxConnections != nil && c.Xmux.maxConcurrency != nil {
|
||||
return nil, errors.New("maxConnections cannot be specified together with maxConcurrency")
|
||||
}
|
||||
|
||||
// Multiplexing config
|
||||
muxProtobuf := splithttp.Multiplexing{
|
||||
MaxConnections: splithttpNewRandRangeConfig(c.Xmux.maxConnections),
|
||||
MaxConcurrency: splithttpNewRandRangeConfig(c.Xmux.maxConcurrency),
|
||||
CMaxReuseTimes: splithttpNewRandRangeConfig(c.Xmux.cMaxReuseTimes),
|
||||
CMaxLifetimeMs: splithttpNewRandRangeConfig(c.Xmux.cMaxLifetimeMs),
|
||||
}
|
||||
|
||||
config := &splithttp.Config{
|
||||
Path: c.Path,
|
||||
Host: c.Host,
|
||||
|
@ -263,6 +284,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) {
|
|||
ScMinPostsIntervalMs: splithttpNewRandRangeConfig(c.ScMinPostsIntervalMs),
|
||||
NoSSEHeader: c.NoSSEHeader,
|
||||
XPaddingBytes: splithttpNewRandRangeConfig(c.XPaddingBytes),
|
||||
Xmux: &muxProtobuf,
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue