Xmux: Value of 0 is treated the same as no value (#3835)

It turns out that some panels like to set `"xmux": {"maxConnections": 0,
"maxConcurrency": 0}`, and of course that fails now. To make their job
easier, let's treat `0` the same as not setting the parameter.

Again, I don't like that xray's defaults are hardcoded all over the
place. I would have liked a different default value for Xmux in a future
version, but it actually can't be done in practice because everybody
just copypastes the defaults from the docs into their own sourcecode
(and sometimes changes them silently to their own idea of a good
default)
This commit is contained in:
mmmray 2024-09-19 17:20:12 +02:00 committed by GitHub
parent 7677ac980d
commit 93cff1a576
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -263,7 +263,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) {
c.Host = c.Headers["Host"] c.Host = c.Headers["Host"]
} }
if c.Xmux.MaxConnections != nil && c.Xmux.MaxConcurrency != nil { if c.Xmux.MaxConnections != nil && c.Xmux.MaxConnections.To > 0 && c.Xmux.MaxConcurrency != nil && c.Xmux.MaxConcurrency.To > 0 {
return nil, errors.New("maxConnections cannot be specified together with maxConcurrency") return nil, errors.New("maxConnections cannot be specified together with maxConcurrency")
} }