From f406b2dee02b4adaa7bb29ac3bf96e0a7ceac4df Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Thu, 19 Sep 2024 02:45:39 +0200 Subject: [PATCH] SplitHTTP client: Fix xmux config deserialization (#3827) --- infra/conf/transport_internet.go | 18 ++++++++-------- transport/internet/splithttp/config.pb.go | 26 +++++++++++------------ transport/internet/splithttp/config.proto | 4 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 67e57c0c..9605d2a2 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -235,10 +235,10 @@ type SplitHTTPConfig struct { } type Xmux struct { - maxConnections *Int32Range `json:"maxConnections"` - maxConcurrency *Int32Range `json:"maxConcurrency"` - cMaxReuseTimes *Int32Range `json:"cMaxReuseTimes"` - cMaxLifetimeMs *Int32Range `json:"cMaxLifetimeMs"` + MaxConcurrency *Int32Range `json:"maxConcurrency"` + MaxConnections *Int32Range `json:"maxConnections"` + CMaxReuseTimes *Int32Range `json:"cMaxReuseTimes"` + CMaxLifetimeMs *Int32Range `json:"cMaxLifetimeMs"` } func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig { @@ -263,16 +263,16 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { c.Host = c.Headers["Host"] } - if c.Xmux.maxConnections != nil && c.Xmux.maxConcurrency != nil { + 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), + MaxConcurrency: splithttpNewRandRangeConfig(c.Xmux.MaxConcurrency), + MaxConnections: splithttpNewRandRangeConfig(c.Xmux.MaxConnections), + CMaxReuseTimes: splithttpNewRandRangeConfig(c.Xmux.CMaxReuseTimes), + CMaxLifetimeMs: splithttpNewRandRangeConfig(c.Xmux.CMaxLifetimeMs), } config := &splithttp.Config{ diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 51fc2091..6bd6a9dd 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -191,8 +191,8 @@ type Multiplexing struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - MaxConnections *RandRangeConfig `protobuf:"bytes,1,opt,name=maxConnections,proto3" json:"maxConnections,omitempty"` - MaxConcurrency *RandRangeConfig `protobuf:"bytes,2,opt,name=maxConcurrency,proto3" json:"maxConcurrency,omitempty"` + MaxConcurrency *RandRangeConfig `protobuf:"bytes,1,opt,name=maxConcurrency,proto3" json:"maxConcurrency,omitempty"` + MaxConnections *RandRangeConfig `protobuf:"bytes,2,opt,name=maxConnections,proto3" json:"maxConnections,omitempty"` CMaxReuseTimes *RandRangeConfig `protobuf:"bytes,3,opt,name=cMaxReuseTimes,proto3" json:"cMaxReuseTimes,omitempty"` CMaxLifetimeMs *RandRangeConfig `protobuf:"bytes,4,opt,name=cMaxLifetimeMs,proto3" json:"cMaxLifetimeMs,omitempty"` } @@ -229,16 +229,16 @@ func (*Multiplexing) Descriptor() ([]byte, []int) { return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{2} } -func (x *Multiplexing) GetMaxConnections() *RandRangeConfig { +func (x *Multiplexing) GetMaxConcurrency() *RandRangeConfig { if x != nil { - return x.MaxConnections + return x.MaxConcurrency } return nil } -func (x *Multiplexing) GetMaxConcurrency() *RandRangeConfig { +func (x *Multiplexing) GetMaxConnections() *RandRangeConfig { if x != nil { - return x.MaxConcurrency + return x.MaxConnections } return nil } @@ -313,17 +313,17 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0xfe, 0x02, 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, - 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, - 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x63, 0x79, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, + 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, @@ -373,8 +373,8 @@ var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ 1, // 3: xray.transport.internet.splithttp.Config.scMinPostsIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 4: xray.transport.internet.splithttp.Config.xPaddingBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig 2, // 5: xray.transport.internet.splithttp.Config.xmux:type_name -> xray.transport.internet.splithttp.Multiplexing - 1, // 6: xray.transport.internet.splithttp.Multiplexing.maxConnections:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 7: xray.transport.internet.splithttp.Multiplexing.maxConcurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 6: xray.transport.internet.splithttp.Multiplexing.maxConcurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 7: xray.transport.internet.splithttp.Multiplexing.maxConnections:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 8: xray.transport.internet.splithttp.Multiplexing.cMaxReuseTimes:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 9: xray.transport.internet.splithttp.Multiplexing.cMaxLifetimeMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig 10, // [10:10] is the sub-list for method output_type diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 019f4d00..249f1e93 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -24,8 +24,8 @@ message RandRangeConfig { } message Multiplexing { - RandRangeConfig maxConnections = 1; - RandRangeConfig maxConcurrency = 2; + RandRangeConfig maxConcurrency = 1; + RandRangeConfig maxConnections = 2; RandRangeConfig cMaxReuseTimes = 3; RandRangeConfig cMaxLifetimeMs = 4; }