From bcb0cb5688735a1d2252b4d2974ba72d812350cc Mon Sep 17 00:00:00 2001 From: YUNRU Date: Sun, 11 Aug 2024 08:33:47 +0800 Subject: [PATCH 01/11] SplitHTTP Client: Multiplexing Config --- infra/conf/transport_internet.go | 31 +++ transport/internet/splithttp/config.go | 24 +- transport/internet/splithttp/config.pb.go | 257 ++++++++++++++++++---- transport/internet/splithttp/config.proto | 13 ++ transport/internet/splithttp/dialer.go | 35 +-- transport/internet/splithttp/mux.go | 115 ++++++++++ 6 files changed, 418 insertions(+), 57 deletions(-) create mode 100644 transport/internet/splithttp/mux.go diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 9e13f246a5af..36d59414fa9f 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -234,6 +234,14 @@ type SplitHTTPConfig struct { ScMinPostsIntervalMs *Int32Range `json:"scMinPostsIntervalMs"` NoSSEHeader bool `json:"noSSEHeader"` XPaddingBytes *Int32Range `json:"xPaddingBytes"` + Mux SplitHTTPMux `json:"mux"` +} + +type SplitHTTPMux struct { + Mode string `json:"mode"` + MaxConnectionConcurrency Int32Range `json:"maxConnectionConcurrency"` + MaxConnectionLifetime Int32Range `json:"maxConnectionLifetime"` + MaxConnection int32 `json:"maxConnection"` } func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig { @@ -257,6 +265,28 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { } else if c.Host == "" && c.Headers["Host"] != "" { c.Host = c.Headers["Host"] } + + // Multiplexing config + muxProtobuf := splithttp.Multiplexing{} + switch strings.ToLower(c.Mux.Mode) { + case "disabled", "off", "none": + muxProtobuf.Mode = splithttp.Multiplexing_DISABLED + case "prefer_reuse", "preferreuse", "prefer_existing", "preferexisting", "": // Default: Reuse existing connections before opening new ones + muxProtobuf.Mode = splithttp.Multiplexing_PREFER_EXTISTING + case "prefer_new", "prefernew": // Open new connections until max limit, then reuse + muxProtobuf.Mode = splithttp.Multiplexing_PREFER_NEW + default: + return nil, errors.New("unsupported splithttp multiplexing mode: ", c.Mux.Mode) + } + muxProtobuf.MaxConnectionConcurrency = &splithttp.RandRangeConfig{ + From: c.Mux.MaxConnectionConcurrency.From, + To: c.Mux.MaxConnectionConcurrency.To, + } + muxProtobuf.MaxConnectionLifetime = &splithttp.RandRangeConfig{ + From: c.Mux.MaxConnectionLifetime.From, + To: c.Mux.MaxConnectionLifetime.To, + } + muxProtobuf.MaxConnections = c.Mux.MaxConnection config := &splithttp.Config{ Path: c.Path, Host: c.Host, @@ -266,6 +296,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { ScMinPostsIntervalMs: splithttpNewRandRangeConfig(c.ScMinPostsIntervalMs), NoSSEHeader: c.NoSSEHeader, XPaddingBytes: splithttpNewRandRangeConfig(c.XPaddingBytes), + Mux: &muxProtobuf, } return config, nil } diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 6b5a2005ea21..4681fd1a2fca 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -53,7 +53,6 @@ func (c *Config) GetRequestHeader() http.Header { return header } - func (c *Config) WriteResponseHeader(writer http.ResponseWriter) { paddingLen := c.GetNormalizedXPaddingBytes().roll() if paddingLen > 0 { @@ -72,6 +71,27 @@ func (c *Config) GetNormalizedScMaxConcurrentPosts() RandRangeConfig { return *c.ScMaxConcurrentPosts } +func (m *Multiplexing) GetNormalizedMaxConnectionConcurrency() RandRangeConfig { + if m.MaxConnectionConcurrency == nil || m.MaxConnectionConcurrency.To == 0 { + return RandRangeConfig{ + From: 1, + To: 3, + } + } + + return *m.MaxConnectionConcurrency +} + +func (c *Multiplexing) GetNormalizedConnectionLifetime() RandRangeConfig { + if c.MaxConnectionLifetime == nil || c.MaxConnectionLifetime.To == 0 { + return RandRangeConfig{ + From: 60000, + To: 90000, + } + } + return *c.MaxConnectionLifetime +} + func (c *Config) GetNormalizedScMaxEachPostBytes() RandRangeConfig { if c.ScMaxEachPostBytes == nil || c.ScMaxEachPostBytes.To == 0 { return RandRangeConfig{ @@ -79,10 +99,8 @@ func (c *Config) GetNormalizedScMaxEachPostBytes() RandRangeConfig { To: 1000000, } } - return *c.ScMaxEachPostBytes } - func (c *Config) GetNormalizedScMinPostsIntervalMs() RandRangeConfig { if c.ScMinPostsIntervalMs == nil || c.ScMinPostsIntervalMs.To == 0 { return RandRangeConfig{ diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 26dbb0b7da53..1c1be9b72e18 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.1 -// protoc v5.27.0 +// protoc v5.27.2 // source: transport/internet/splithttp/config.proto package splithttp @@ -20,6 +20,55 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type Multiplexing_MultiplexingMode int32 + +const ( + Multiplexing_DISABLED Multiplexing_MultiplexingMode = 0 + Multiplexing_PREFER_EXTISTING Multiplexing_MultiplexingMode = 1 + Multiplexing_PREFER_NEW Multiplexing_MultiplexingMode = 2 +) + +// Enum value maps for Multiplexing_MultiplexingMode. +var ( + Multiplexing_MultiplexingMode_name = map[int32]string{ + 0: "DISABLED", + 1: "PREFER_EXTISTING", + 2: "PREFER_NEW", + } + Multiplexing_MultiplexingMode_value = map[string]int32{ + "DISABLED": 0, + "PREFER_EXTISTING": 1, + "PREFER_NEW": 2, + } +) + +func (x Multiplexing_MultiplexingMode) Enum() *Multiplexing_MultiplexingMode { + p := new(Multiplexing_MultiplexingMode) + *p = x + return p +} + +func (x Multiplexing_MultiplexingMode) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Multiplexing_MultiplexingMode) Descriptor() protoreflect.EnumDescriptor { + return file_transport_internet_splithttp_config_proto_enumTypes[0].Descriptor() +} + +func (Multiplexing_MultiplexingMode) Type() protoreflect.EnumType { + return &file_transport_internet_splithttp_config_proto_enumTypes[0] +} + +func (x Multiplexing_MultiplexingMode) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Multiplexing_MultiplexingMode.Descriptor instead. +func (Multiplexing_MultiplexingMode) EnumDescriptor() ([]byte, []int) { + return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{2, 0} +} + type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -33,6 +82,7 @@ type Config struct { ScMinPostsIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` NoSSEHeader bool `protobuf:"varint,7,opt,name=noSSEHeader,proto3" json:"noSSEHeader,omitempty"` XPaddingBytes *RandRangeConfig `protobuf:"bytes,8,opt,name=xPaddingBytes,proto3" json:"xPaddingBytes,omitempty"` + Mux *Multiplexing `protobuf:"bytes,9,opt,name=mux,proto3" json:"mux,omitempty"` } func (x *Config) Reset() { @@ -123,6 +173,13 @@ func (x *Config) GetXPaddingBytes() *RandRangeConfig { return nil } +func (x *Config) GetMux() *Multiplexing { + if x != nil { + return x.Mux + } + return nil +} + type RandRangeConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -178,6 +235,77 @@ func (x *RandRangeConfig) GetTo() int32 { return 0 } +type Multiplexing struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Mode Multiplexing_MultiplexingMode `protobuf:"varint,3,opt,name=mode,proto3,enum=xray.transport.internet.splithttp.Multiplexing_MultiplexingMode" json:"mode,omitempty"` + MaxConnectionConcurrency *RandRangeConfig `protobuf:"bytes,4,opt,name=maxConnectionConcurrency,proto3" json:"maxConnectionConcurrency,omitempty"` + MaxConnectionLifetime *RandRangeConfig `protobuf:"bytes,5,opt,name=maxConnectionLifetime,proto3" json:"maxConnectionLifetime,omitempty"` + MaxConnections int32 `protobuf:"varint,6,opt,name=maxConnections,proto3" json:"maxConnections,omitempty"` +} + +func (x *Multiplexing) Reset() { + *x = Multiplexing{} + if protoimpl.UnsafeEnabled { + mi := &file_transport_internet_splithttp_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Multiplexing) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Multiplexing) ProtoMessage() {} + +func (x *Multiplexing) ProtoReflect() protoreflect.Message { + mi := &file_transport_internet_splithttp_config_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Multiplexing.ProtoReflect.Descriptor instead. +func (*Multiplexing) Descriptor() ([]byte, []int) { + return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{2} +} + +func (x *Multiplexing) GetMode() Multiplexing_MultiplexingMode { + if x != nil { + return x.Mode + } + return Multiplexing_DISABLED +} + +func (x *Multiplexing) GetMaxConnectionConcurrency() *RandRangeConfig { + if x != nil { + return x.MaxConnectionConcurrency + } + return nil +} + +func (x *Multiplexing) GetMaxConnectionLifetime() *RandRangeConfig { + if x != nil { + return x.MaxConnectionLifetime + } + return nil +} + +func (x *Multiplexing) GetMaxConnections() int32 { + if x != nil { + return x.MaxConnections + } + return 0 +} + var File_transport_internet_splithttp_config_proto protoreflect.FileDescriptor var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ @@ -185,8 +313,8 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 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, 0x22, 0xec, - 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xad, + 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, @@ -215,29 +343,60 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, - 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x5a, 0x0a, 0x0e, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, - 0x6e, 0x67, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x58, 0x0a, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, + 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x08, 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, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, + 0x12, 0x41, 0x0a, 0x03, 0x6d, 0x75, 0x78, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 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, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x52, 0x03, + 0x6d, 0x75, 0x78, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, + 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0xae, 0x03, 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, + 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x54, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x40, 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, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, + 0x65, 0x78, 0x69, 0x6e, 0x67, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, + 0x6e, 0x67, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x6e, 0x0a, 0x18, + 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, + 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x04, 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, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, - 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, - 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, - 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x02, 0x74, 0x6f, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 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, 0x50, 0x01, - 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, - 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, - 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, - 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x69, 0x67, 0x52, 0x18, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x68, 0x0a, 0x15, + 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x66, + 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 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, + 0x15, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, + 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, + 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x46, + 0x0a, 0x10, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x4d, 0x6f, + 0x64, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x44, 0x49, 0x53, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x00, + 0x12, 0x14, 0x0a, 0x10, 0x50, 0x52, 0x45, 0x46, 0x45, 0x52, 0x5f, 0x45, 0x58, 0x54, 0x49, 0x53, + 0x54, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x50, 0x52, 0x45, 0x46, 0x45, 0x52, + 0x5f, 0x4e, 0x45, 0x57, 0x10, 0x02, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 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, + 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, + 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, + 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -252,23 +411,30 @@ func file_transport_internet_splithttp_config_proto_rawDescGZIP() []byte { return file_transport_internet_splithttp_config_proto_rawDescData } -var file_transport_internet_splithttp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_transport_internet_splithttp_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_transport_internet_splithttp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_transport_internet_splithttp_config_proto_goTypes = []interface{}{ - (*Config)(nil), // 0: xray.transport.internet.splithttp.Config - (*RandRangeConfig)(nil), // 1: xray.transport.internet.splithttp.RandRangeConfig - nil, // 2: xray.transport.internet.splithttp.Config.HeaderEntry + (Multiplexing_MultiplexingMode)(0), // 0: xray.transport.internet.splithttp.Multiplexing.MultiplexingMode + (*Config)(nil), // 1: xray.transport.internet.splithttp.Config + (*RandRangeConfig)(nil), // 2: xray.transport.internet.splithttp.RandRangeConfig + (*Multiplexing)(nil), // 3: xray.transport.internet.splithttp.Multiplexing + nil, // 4: xray.transport.internet.splithttp.Config.HeaderEntry } var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ - 2, // 0: xray.transport.internet.splithttp.Config.header:type_name -> xray.transport.internet.splithttp.Config.HeaderEntry - 1, // 1: xray.transport.internet.splithttp.Config.scMaxConcurrentPosts:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 2: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 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 - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 4, // 0: xray.transport.internet.splithttp.Config.header:type_name -> xray.transport.internet.splithttp.Config.HeaderEntry + 2, // 1: xray.transport.internet.splithttp.Config.scMaxConcurrentPosts:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 2, // 2: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 2, // 3: xray.transport.internet.splithttp.Config.scMinPostsIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 2, // 4: xray.transport.internet.splithttp.Config.xPaddingBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 3, // 5: xray.transport.internet.splithttp.Config.mux:type_name -> xray.transport.internet.splithttp.Multiplexing + 0, // 6: xray.transport.internet.splithttp.Multiplexing.mode:type_name -> xray.transport.internet.splithttp.Multiplexing.MultiplexingMode + 2, // 7: xray.transport.internet.splithttp.Multiplexing.maxConnectionConcurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 2, // 8: xray.transport.internet.splithttp.Multiplexing.maxConnectionLifetime:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 9, // [9:9] is the sub-list for method output_type + 9, // [9:9] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_transport_internet_splithttp_config_proto_init() } @@ -301,19 +467,32 @@ func file_transport_internet_splithttp_config_proto_init() { return nil } } + file_transport_internet_splithttp_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Multiplexing); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_transport_internet_splithttp_config_proto_rawDesc, - NumEnums: 0, - NumMessages: 3, + NumEnums: 1, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, GoTypes: file_transport_internet_splithttp_config_proto_goTypes, DependencyIndexes: file_transport_internet_splithttp_config_proto_depIdxs, + EnumInfos: file_transport_internet_splithttp_config_proto_enumTypes, MessageInfos: file_transport_internet_splithttp_config_proto_msgTypes, }.Build() File_transport_internet_splithttp_config_proto = out.File diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 3f24cfd3ba54..02ca552512b5 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -15,9 +15,22 @@ message Config { RandRangeConfig scMinPostsIntervalMs = 6; bool noSSEHeader = 7; RandRangeConfig xPaddingBytes = 8; + Multiplexing mux = 9; } message RandRangeConfig { int32 from = 1; int32 to = 2; } + +message Multiplexing { + enum MultiplexingMode { + DISABLED = 0; + PREFER_EXTISTING = 1; + PREFER_NEW = 2; + } + MultiplexingMode mode = 3; + RandRangeConfig maxConnectionConcurrency = 4; + RandRangeConfig maxConnectionLifetime = 5; + int32 maxConnections = 6; +} diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 45bdc6459c7b..296d22595f62 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -43,8 +43,8 @@ type dialerConf struct { } var ( - globalDialerMap map[dialerConf]DialerClient - globalDialerAccess sync.Mutex + globalDialerAccess sync.Mutex + globalMuxManagerMap map[dialerConf]muxManager ) func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) DialerClient { @@ -52,23 +52,29 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in return &BrowserDialerClient{} } - tlsConfig := tls.ConfigFromStreamSettings(streamSettings) - isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1") - isH3 := tlsConfig != nil && (len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3") - globalDialerAccess.Lock() defer globalDialerAccess.Unlock() - if globalDialerMap == nil { - globalDialerMap = make(map[dialerConf]DialerClient) + if globalMuxManagerMap == nil { + globalMuxManagerMap = make(map[dialerConf]muxManager) } + if muxMan, found := globalMuxManagerMap[dialerConf{dest, streamSettings}]; found { + return muxMan.getClient(ctx, dest, streamSettings) + } + muxMan := muxManager{} + globalMuxManagerMap[dialerConf{dest, streamSettings}] = muxMan + return muxMan.getClient(ctx, dest, streamSettings) +} + +func createHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) *DefaultDialerClient { + + tlsConfig := tls.ConfigFromStreamSettings(streamSettings) + isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1") + isH3 := tlsConfig != nil && (len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3") if isH3 { dest.Network = net.Network_UDP } - if client, found := globalDialerMap[dialerConf{dest, streamSettings}]; found { - return client - } var gotlsConfig *gotls.Config @@ -173,7 +179,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in uploadTransport = nil } - client := &DefaultDialerClient{ + client := DefaultDialerClient{ transportConfig: streamSettings.ProtocolSettings.(*Config), download: &http.Client{ Transport: downloadTransport, @@ -187,8 +193,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in dialUploadConn: dialContext, } - globalDialerMap[dialerConf{dest, streamSettings}] = client - return client + return &client } func init() { @@ -202,7 +207,6 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me transportConfiguration := streamSettings.ProtocolSettings.(*Config) tlsConfig := tls.ConfigFromStreamSettings(streamSettings) - scMaxConcurrentPosts := transportConfiguration.GetNormalizedScMaxConcurrentPosts() scMaxEachPostBytes := transportConfiguration.GetNormalizedScMaxEachPostBytes() scMinPostsIntervalMs := transportConfiguration.GetNormalizedScMinPostsIntervalMs() @@ -235,6 +239,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me // calls get automatically batched together into larger POST requests. // without batching, bandwidth is extremely limited. for { + chunk, err := uploadPipeReader.ReadMultiBuffer() if err != nil { break diff --git a/transport/internet/splithttp/mux.go b/transport/internet/splithttp/mux.go new file mode 100644 index 000000000000..3fa1c0596920 --- /dev/null +++ b/transport/internet/splithttp/mux.go @@ -0,0 +1,115 @@ +package splithttp + +import ( + "context" + "sync" + "time" + + "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/transport/internet" +) + +type muxDialerClient struct { + *DefaultDialerClient + leftUsage int32 + expirationTime time.Time +} + +type muxManager struct { + sync.Mutex + config *Multiplexing + dialerClients []muxDialerClient +} + +func newMuxManager(config *Multiplexing) *muxManager { + return &muxManager{ + config: config, + dialerClients: make([]muxDialerClient, 0), + } +} + +func (m *muxManager) getClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) *muxDialerClient { + m.Lock() + defer m.Unlock() + if len(m.dialerClients) > 0 { + m.removeExpiredConnections() + } + switch m.config.GetMode() { + case Multiplexing_PREFER_EXTISTING: + return m.dialPreferExisting(ctx, dest, streamSettings) + case Multiplexing_PREFER_NEW: + return m.dialPreferNew(ctx, dest, streamSettings) + default: + return &muxDialerClient{ + DefaultDialerClient: createHTTPClient(ctx, dest, streamSettings), + } + } +} + +func (m *muxManager) dialPreferExisting(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) *muxDialerClient { + for { + for _, client := range m.dialerClients { + if m.canReuseClient(client) { + client.leftUsage-- + return &client + } + } + if int32(len(m.dialerClients)) >= m.config.GetMaxConnections() || m.config.GetMaxConnections() == 0 { + if streamSettings.ProtocolSettings.(*Config).GetNormalizedScMinPostsIntervalMs().From > 0 { + time.Sleep(time.Duration(streamSettings.ProtocolSettings.(*Config).GetNormalizedScMinPostsIntervalMs().roll()) * time.Millisecond) + } + continue + } + break + } + return m.newClient(ctx, dest, streamSettings) +} + +func (m *muxManager) dialPreferNew(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) *muxDialerClient { + for { + if int32(len(m.dialerClients)) < m.config.MaxConnections || m.config.MaxConnections == 0 { + return m.newClient(ctx, dest, streamSettings) + } + + for _, client := range m.dialerClients { + if m.canReuseClient(client) { + client.leftUsage-- + return &client + } + } + if streamSettings.ProtocolSettings.(*Config).GetNormalizedScMinPostsIntervalMs().From > 0 { + time.Sleep(time.Duration(streamSettings.ProtocolSettings.(*Config).GetNormalizedScMinPostsIntervalMs().roll()) * time.Millisecond) + } + continue + } +} + +func (m *muxManager) newClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) *muxDialerClient { + m.Lock() + defer m.Unlock() + + Client := muxDialerClient{ + DefaultDialerClient: createHTTPClient(ctx, dest, streamSettings), + leftUsage: m.config.GetNormalizedMaxConnectionConcurrency().roll(), + expirationTime: time.Now().Add(time.Duration(m.config.GetNormalizedConnectionLifetime().roll()) * time.Second), + } + m.dialerClients = append(m.dialerClients, Client) + return &Client +} + +func (m *muxManager) removeExpiredConnections() { + m.Lock() + defer m.Unlock() + + for i := 0; i < len(m.dialerClients); i++ { + client := m.dialerClients[i] + if time.Now().After(client.expirationTime) || client.leftUsage <= 0 { + m.dialerClients = append(m.dialerClients[:i], m.dialerClients[i+1:]...) + i-- + } + } +} + +func (m *muxManager) canReuseClient(c muxDialerClient) bool { + return c.leftUsage > 0 && time.Now().Before(c.expirationTime) +} From df4da35ee3db85ddbff258ccf47434b7ea2f7e5c Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Thu, 29 Aug 2024 15:53:04 -0500 Subject: [PATCH 02/11] regenerate pb.go --- transport/internet/splithttp/config.pb.go | 82 ++++++++++++++++------- 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 0fba34ae9d07..55060ba53f7d 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -313,8 +313,8 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 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, 0x22, 0xea, - 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xad, + 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, @@ -349,23 +349,54 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 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, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, - 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, - 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, - 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, - 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, - 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, - 0x74, 0x6f, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 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, 0x50, 0x01, 0x5a, 0x36, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, - 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, - 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x12, 0x41, 0x0a, 0x03, 0x6d, 0x75, 0x78, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 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, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x52, 0x03, + 0x6d, 0x75, 0x78, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, + 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0xae, 0x03, 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, + 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x54, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x40, 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, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, + 0x65, 0x78, 0x69, 0x6e, 0x67, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, + 0x6e, 0x67, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x6e, 0x0a, 0x18, + 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, + 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x04, 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, 0x18, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x68, 0x0a, 0x15, + 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x66, + 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 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, + 0x15, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, + 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, + 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x46, + 0x0a, 0x10, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x4d, 0x6f, + 0x64, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x44, 0x49, 0x53, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x00, + 0x12, 0x14, 0x0a, 0x10, 0x50, 0x52, 0x45, 0x46, 0x45, 0x52, 0x5f, 0x45, 0x58, 0x54, 0x49, 0x53, + 0x54, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x50, 0x52, 0x45, 0x46, 0x45, 0x52, + 0x5f, 0x4e, 0x45, 0x57, 0x10, 0x02, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 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, + 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, + 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, + 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -380,11 +411,14 @@ func file_transport_internet_splithttp_config_proto_rawDescGZIP() []byte { return file_transport_internet_splithttp_config_proto_rawDescData } -var file_transport_internet_splithttp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_transport_internet_splithttp_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_transport_internet_splithttp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_transport_internet_splithttp_config_proto_goTypes = []any{ - (*Config)(nil), // 0: xray.transport.internet.splithttp.Config - (*RandRangeConfig)(nil), // 1: xray.transport.internet.splithttp.RandRangeConfig - nil, // 2: xray.transport.internet.splithttp.Config.HeaderEntry + (Multiplexing_MultiplexingMode)(0), // 0: xray.transport.internet.splithttp.Multiplexing.MultiplexingMode + (*Config)(nil), // 1: xray.transport.internet.splithttp.Config + (*RandRangeConfig)(nil), // 2: xray.transport.internet.splithttp.RandRangeConfig + (*Multiplexing)(nil), // 3: xray.transport.internet.splithttp.Multiplexing + nil, // 4: xray.transport.internet.splithttp.Config.HeaderEntry } var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ 4, // 0: xray.transport.internet.splithttp.Config.header:type_name -> xray.transport.internet.splithttp.Config.HeaderEntry @@ -433,7 +467,7 @@ func file_transport_internet_splithttp_config_proto_init() { return nil } } - file_transport_internet_splithttp_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_splithttp_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Multiplexing); i { case 0: return &v.state From b19984e4e86d466df53872d7af55b733fe8730d3 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Thu, 29 Aug 2024 20:44:29 -0500 Subject: [PATCH 03/11] Move to RoundTripper layer, change API and add tests --- infra/conf/transport_internet.go | 37 ++-- transport/internet/splithttp/config.go | 64 ++++--- transport/internet/splithttp/config.pb.go | 211 ++++++++-------------- transport/internet/splithttp/config.proto | 15 +- transport/internet/splithttp/dialer.go | 131 +++++++------- transport/internet/splithttp/mux.go | 168 ++++++++++------- transport/internet/splithttp/mux_test.go | 93 ++++++++++ 7 files changed, 400 insertions(+), 319 deletions(-) create mode 100644 transport/internet/splithttp/mux_test.go diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 36d59414fa9f..832d44ddab49 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -234,14 +234,14 @@ type SplitHTTPConfig struct { ScMinPostsIntervalMs *Int32Range `json:"scMinPostsIntervalMs"` NoSSEHeader bool `json:"noSSEHeader"` XPaddingBytes *Int32Range `json:"xPaddingBytes"` - Mux SplitHTTPMux `json:"mux"` + HttpMux SplitHTTPMux `json:"httpMux"` } type SplitHTTPMux struct { - Mode string `json:"mode"` - MaxConnectionConcurrency Int32Range `json:"maxConnectionConcurrency"` - MaxConnectionLifetime Int32Range `json:"maxConnectionLifetime"` - MaxConnection int32 `json:"maxConnection"` + RequestsPerConnection *Int32Range `json:"requestsPerConnection"` + ConnectionLifetimeMs *Int32Range `json:"connectionLifetimeMs"` + Connections *Int32Range `json:"connections"` + Concurrency *Int32Range `json:"concurrency"` } func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig { @@ -267,26 +267,13 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { } // Multiplexing config - muxProtobuf := splithttp.Multiplexing{} - switch strings.ToLower(c.Mux.Mode) { - case "disabled", "off", "none": - muxProtobuf.Mode = splithttp.Multiplexing_DISABLED - case "prefer_reuse", "preferreuse", "prefer_existing", "preferexisting", "": // Default: Reuse existing connections before opening new ones - muxProtobuf.Mode = splithttp.Multiplexing_PREFER_EXTISTING - case "prefer_new", "prefernew": // Open new connections until max limit, then reuse - muxProtobuf.Mode = splithttp.Multiplexing_PREFER_NEW - default: - return nil, errors.New("unsupported splithttp multiplexing mode: ", c.Mux.Mode) - } - muxProtobuf.MaxConnectionConcurrency = &splithttp.RandRangeConfig{ - From: c.Mux.MaxConnectionConcurrency.From, - To: c.Mux.MaxConnectionConcurrency.To, + muxProtobuf := splithttp.Multiplexing{ + RequestsPerConnection: splithttpNewRandRangeConfig(c.HttpMux.RequestsPerConnection), + ConnectionLifetimeMs: splithttpNewRandRangeConfig(c.HttpMux.ConnectionLifetimeMs), + Connections: splithttpNewRandRangeConfig(c.HttpMux.Connections), + Concurrency: splithttpNewRandRangeConfig(c.HttpMux.Concurrency), } - muxProtobuf.MaxConnectionLifetime = &splithttp.RandRangeConfig{ - From: c.Mux.MaxConnectionLifetime.From, - To: c.Mux.MaxConnectionLifetime.To, - } - muxProtobuf.MaxConnections = c.Mux.MaxConnection + config := &splithttp.Config{ Path: c.Path, Host: c.Host, @@ -296,7 +283,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { ScMinPostsIntervalMs: splithttpNewRandRangeConfig(c.ScMinPostsIntervalMs), NoSSEHeader: c.NoSSEHeader, XPaddingBytes: splithttpNewRandRangeConfig(c.XPaddingBytes), - Mux: &muxProtobuf, + HttpMux: &muxProtobuf, } return config, nil } diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 4681fd1a2fca..5ff20b2c5bf3 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -71,27 +71,6 @@ func (c *Config) GetNormalizedScMaxConcurrentPosts() RandRangeConfig { return *c.ScMaxConcurrentPosts } -func (m *Multiplexing) GetNormalizedMaxConnectionConcurrency() RandRangeConfig { - if m.MaxConnectionConcurrency == nil || m.MaxConnectionConcurrency.To == 0 { - return RandRangeConfig{ - From: 1, - To: 3, - } - } - - return *m.MaxConnectionConcurrency -} - -func (c *Multiplexing) GetNormalizedConnectionLifetime() RandRangeConfig { - if c.MaxConnectionLifetime == nil || c.MaxConnectionLifetime.To == 0 { - return RandRangeConfig{ - From: 60000, - To: 90000, - } - } - return *c.MaxConnectionLifetime -} - func (c *Config) GetNormalizedScMaxEachPostBytes() RandRangeConfig { if c.ScMaxEachPostBytes == nil || c.ScMaxEachPostBytes.To == 0 { return RandRangeConfig{ @@ -123,6 +102,49 @@ func (c *Config) GetNormalizedXPaddingBytes() RandRangeConfig { return *c.XPaddingBytes } +func (m *Multiplexing) GetNormalizedRequestsPerConnection() RandRangeConfig { + if m.RequestsPerConnection == nil { + return RandRangeConfig{ + From: 0, + To: 0, + } + } + + return *m.RequestsPerConnection +} + +func (m *Multiplexing) GetNormalizedConnectionLifetimeMs() RandRangeConfig { + if m.ConnectionLifetimeMs == nil || m.ConnectionLifetimeMs.To == 0 { + return RandRangeConfig{ + From: 0, + To: 0, + } + } + return *m.ConnectionLifetimeMs +} + +func (m *Multiplexing) GetNormalizedConnections() RandRangeConfig { + if m.Connections == nil { + return RandRangeConfig{ + From: 0, + To: 0, + } + } + + return *m.Connections +} + +func (m *Multiplexing) GetNormalizedConcurrency() RandRangeConfig { + if m.Concurrency == nil { + return RandRangeConfig{ + From: 0, + To: 0, + } + } + + return *m.Concurrency +} + func init() { common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} { return new(Config) diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 55060ba53f7d..53db29b4f3f5 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -20,55 +20,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type Multiplexing_MultiplexingMode int32 - -const ( - Multiplexing_DISABLED Multiplexing_MultiplexingMode = 0 - Multiplexing_PREFER_EXTISTING Multiplexing_MultiplexingMode = 1 - Multiplexing_PREFER_NEW Multiplexing_MultiplexingMode = 2 -) - -// Enum value maps for Multiplexing_MultiplexingMode. -var ( - Multiplexing_MultiplexingMode_name = map[int32]string{ - 0: "DISABLED", - 1: "PREFER_EXTISTING", - 2: "PREFER_NEW", - } - Multiplexing_MultiplexingMode_value = map[string]int32{ - "DISABLED": 0, - "PREFER_EXTISTING": 1, - "PREFER_NEW": 2, - } -) - -func (x Multiplexing_MultiplexingMode) Enum() *Multiplexing_MultiplexingMode { - p := new(Multiplexing_MultiplexingMode) - *p = x - return p -} - -func (x Multiplexing_MultiplexingMode) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Multiplexing_MultiplexingMode) Descriptor() protoreflect.EnumDescriptor { - return file_transport_internet_splithttp_config_proto_enumTypes[0].Descriptor() -} - -func (Multiplexing_MultiplexingMode) Type() protoreflect.EnumType { - return &file_transport_internet_splithttp_config_proto_enumTypes[0] -} - -func (x Multiplexing_MultiplexingMode) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Multiplexing_MultiplexingMode.Descriptor instead. -func (Multiplexing_MultiplexingMode) EnumDescriptor() ([]byte, []int) { - return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{2, 0} -} - type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -82,7 +33,7 @@ type Config struct { ScMinPostsIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` NoSSEHeader bool `protobuf:"varint,7,opt,name=noSSEHeader,proto3" json:"noSSEHeader,omitempty"` XPaddingBytes *RandRangeConfig `protobuf:"bytes,8,opt,name=xPaddingBytes,proto3" json:"xPaddingBytes,omitempty"` - Mux *Multiplexing `protobuf:"bytes,9,opt,name=mux,proto3" json:"mux,omitempty"` + HttpMux *Multiplexing `protobuf:"bytes,9,opt,name=httpMux,proto3" json:"httpMux,omitempty"` } func (x *Config) Reset() { @@ -173,9 +124,9 @@ func (x *Config) GetXPaddingBytes() *RandRangeConfig { return nil } -func (x *Config) GetMux() *Multiplexing { +func (x *Config) GetHttpMux() *Multiplexing { if x != nil { - return x.Mux + return x.HttpMux } return nil } @@ -240,10 +191,10 @@ type Multiplexing struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Mode Multiplexing_MultiplexingMode `protobuf:"varint,3,opt,name=mode,proto3,enum=xray.transport.internet.splithttp.Multiplexing_MultiplexingMode" json:"mode,omitempty"` - MaxConnectionConcurrency *RandRangeConfig `protobuf:"bytes,4,opt,name=maxConnectionConcurrency,proto3" json:"maxConnectionConcurrency,omitempty"` - MaxConnectionLifetime *RandRangeConfig `protobuf:"bytes,5,opt,name=maxConnectionLifetime,proto3" json:"maxConnectionLifetime,omitempty"` - MaxConnections int32 `protobuf:"varint,6,opt,name=maxConnections,proto3" json:"maxConnections,omitempty"` + RequestsPerConnection *RandRangeConfig `protobuf:"bytes,4,opt,name=requestsPerConnection,proto3" json:"requestsPerConnection,omitempty"` + ConnectionLifetimeMs *RandRangeConfig `protobuf:"bytes,5,opt,name=connectionLifetimeMs,proto3" json:"connectionLifetimeMs,omitempty"` + Connections *RandRangeConfig `protobuf:"bytes,6,opt,name=connections,proto3" json:"connections,omitempty"` + Concurrency *RandRangeConfig `protobuf:"bytes,7,opt,name=concurrency,proto3" json:"concurrency,omitempty"` } func (x *Multiplexing) Reset() { @@ -278,32 +229,32 @@ func (*Multiplexing) Descriptor() ([]byte, []int) { return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{2} } -func (x *Multiplexing) GetMode() Multiplexing_MultiplexingMode { +func (x *Multiplexing) GetRequestsPerConnection() *RandRangeConfig { if x != nil { - return x.Mode + return x.RequestsPerConnection } - return Multiplexing_DISABLED + return nil } -func (x *Multiplexing) GetMaxConnectionConcurrency() *RandRangeConfig { +func (x *Multiplexing) GetConnectionLifetimeMs() *RandRangeConfig { if x != nil { - return x.MaxConnectionConcurrency + return x.ConnectionLifetimeMs } return nil } -func (x *Multiplexing) GetMaxConnectionLifetime() *RandRangeConfig { +func (x *Multiplexing) GetConnections() *RandRangeConfig { if x != nil { - return x.MaxConnectionLifetime + return x.Connections } return nil } -func (x *Multiplexing) GetMaxConnections() int32 { +func (x *Multiplexing) GetConcurrency() *RandRangeConfig { if x != nil { - return x.MaxConnections + return x.Concurrency } - return 0 + return nil } var File_transport_internet_splithttp_config_proto protoreflect.FileDescriptor @@ -313,7 +264,7 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 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, 0x22, 0xad, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xb5, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, @@ -349,54 +300,52 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 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, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, - 0x12, 0x41, 0x0a, 0x03, 0x6d, 0x75, 0x78, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, + 0x12, 0x49, 0x0a, 0x07, 0x68, 0x74, 0x74, 0x70, 0x4d, 0x75, 0x78, 0x18, 0x09, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2f, 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, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, + 0x6e, 0x67, 0x52, 0x07, 0x68, 0x74, 0x74, 0x70, 0x4d, 0x75, 0x78, 0x1a, 0x39, 0x0a, 0x0b, 0x48, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, + 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, + 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, + 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0x8c, 0x03, + 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x68, + 0x0a, 0x15, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x50, 0x65, 0x72, 0x43, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 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, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x52, 0x03, - 0x6d, 0x75, 0x78, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, - 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0xae, 0x03, 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, - 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x54, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x40, 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, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, - 0x65, 0x78, 0x69, 0x6e, 0x67, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, - 0x6e, 0x67, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x6e, 0x0a, 0x18, - 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, - 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x04, 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, 0x18, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x68, 0x0a, 0x15, - 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x66, - 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, + 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x52, 0x15, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x50, 0x65, 0x72, 0x43, 0x6f, + 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x66, 0x0a, 0x14, 0x63, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, + 0x18, 0x05, 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, 0x14, 0x63, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, + 0x12, 0x54, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0x06, 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, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x54, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x07, 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, - 0x15, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, - 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, - 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, - 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x46, - 0x0a, 0x10, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x4d, 0x6f, - 0x64, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x44, 0x49, 0x53, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x00, - 0x12, 0x14, 0x0a, 0x10, 0x50, 0x52, 0x45, 0x46, 0x45, 0x52, 0x5f, 0x45, 0x58, 0x54, 0x49, 0x53, - 0x54, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x50, 0x52, 0x45, 0x46, 0x45, 0x52, - 0x5f, 0x4e, 0x45, 0x57, 0x10, 0x02, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 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, - 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, - 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, - 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x42, 0x85, 0x01, 0x0a, + 0x25, 0x63, 0x6f, 0x6d, 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, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, + 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, + 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, + 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -411,30 +360,29 @@ func file_transport_internet_splithttp_config_proto_rawDescGZIP() []byte { return file_transport_internet_splithttp_config_proto_rawDescData } -var file_transport_internet_splithttp_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_transport_internet_splithttp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_transport_internet_splithttp_config_proto_goTypes = []any{ - (Multiplexing_MultiplexingMode)(0), // 0: xray.transport.internet.splithttp.Multiplexing.MultiplexingMode - (*Config)(nil), // 1: xray.transport.internet.splithttp.Config - (*RandRangeConfig)(nil), // 2: xray.transport.internet.splithttp.RandRangeConfig - (*Multiplexing)(nil), // 3: xray.transport.internet.splithttp.Multiplexing - nil, // 4: xray.transport.internet.splithttp.Config.HeaderEntry + (*Config)(nil), // 0: xray.transport.internet.splithttp.Config + (*RandRangeConfig)(nil), // 1: xray.transport.internet.splithttp.RandRangeConfig + (*Multiplexing)(nil), // 2: xray.transport.internet.splithttp.Multiplexing + nil, // 3: xray.transport.internet.splithttp.Config.HeaderEntry } var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ - 4, // 0: xray.transport.internet.splithttp.Config.header:type_name -> xray.transport.internet.splithttp.Config.HeaderEntry - 2, // 1: xray.transport.internet.splithttp.Config.scMaxConcurrentPosts:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 2, // 2: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 2, // 3: xray.transport.internet.splithttp.Config.scMinPostsIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 2, // 4: xray.transport.internet.splithttp.Config.xPaddingBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 3, // 5: xray.transport.internet.splithttp.Config.mux:type_name -> xray.transport.internet.splithttp.Multiplexing - 0, // 6: xray.transport.internet.splithttp.Multiplexing.mode:type_name -> xray.transport.internet.splithttp.Multiplexing.MultiplexingMode - 2, // 7: xray.transport.internet.splithttp.Multiplexing.maxConnectionConcurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 2, // 8: xray.transport.internet.splithttp.Multiplexing.maxConnectionLifetime:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 9, // [9:9] is the sub-list for method output_type - 9, // [9:9] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 3, // 0: xray.transport.internet.splithttp.Config.header:type_name -> xray.transport.internet.splithttp.Config.HeaderEntry + 1, // 1: xray.transport.internet.splithttp.Config.scMaxConcurrentPosts:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 2: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 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.httpMux:type_name -> xray.transport.internet.splithttp.Multiplexing + 1, // 6: xray.transport.internet.splithttp.Multiplexing.requestsPerConnection:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 7: xray.transport.internet.splithttp.Multiplexing.connectionLifetimeMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 8: xray.transport.internet.splithttp.Multiplexing.connections:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 9: xray.transport.internet.splithttp.Multiplexing.concurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_transport_internet_splithttp_config_proto_init() } @@ -485,14 +433,13 @@ func file_transport_internet_splithttp_config_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_transport_internet_splithttp_config_proto_rawDesc, - NumEnums: 1, + NumEnums: 0, NumMessages: 4, NumExtensions: 0, NumServices: 0, }, GoTypes: file_transport_internet_splithttp_config_proto_goTypes, DependencyIndexes: file_transport_internet_splithttp_config_proto_depIdxs, - EnumInfos: file_transport_internet_splithttp_config_proto_enumTypes, MessageInfos: file_transport_internet_splithttp_config_proto_msgTypes, }.Build() File_transport_internet_splithttp_config_proto = out.File diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 02ca552512b5..9f969ca2b5bd 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -15,7 +15,7 @@ message Config { RandRangeConfig scMinPostsIntervalMs = 6; bool noSSEHeader = 7; RandRangeConfig xPaddingBytes = 8; - Multiplexing mux = 9; + Multiplexing httpMux = 9; } message RandRangeConfig { @@ -24,13 +24,8 @@ message RandRangeConfig { } message Multiplexing { - enum MultiplexingMode { - DISABLED = 0; - PREFER_EXTISTING = 1; - PREFER_NEW = 2; - } - MultiplexingMode mode = 3; - RandRangeConfig maxConnectionConcurrency = 4; - RandRangeConfig maxConnectionLifetime = 5; - int32 maxConnections = 6; + RandRangeConfig requestsPerConnection = 4; + RandRangeConfig connectionLifetimeMs = 5; + RandRangeConfig connections = 6; + RandRangeConfig concurrency = 7; } diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index afc4d226fdd7..e820cfd5ccfc 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -41,8 +41,8 @@ type dialerConf struct { } var ( - globalDialerAccess sync.Mutex - globalMuxManagerMap map[dialerConf]muxManager + globalDialerMap map[dialerConf]DialerClient + globalDialerAccess sync.Mutex ) func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) DialerClient { @@ -50,29 +50,23 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in return &BrowserDialerClient{} } + tlsConfig := tls.ConfigFromStreamSettings(streamSettings) + isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1") + isH3 := tlsConfig != nil && (len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3") + globalDialerAccess.Lock() defer globalDialerAccess.Unlock() - if globalMuxManagerMap == nil { - globalMuxManagerMap = make(map[dialerConf]muxManager) - } - if muxMan, found := globalMuxManagerMap[dialerConf{dest, streamSettings}]; found { - return muxMan.getClient(ctx, dest, streamSettings) + if globalDialerMap == nil { + globalDialerMap = make(map[dialerConf]DialerClient) } - muxMan := muxManager{} - globalMuxManagerMap[dialerConf{dest, streamSettings}] = muxMan - return muxMan.getClient(ctx, dest, streamSettings) -} - -func createHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) *DefaultDialerClient { - - tlsConfig := tls.ConfigFromStreamSettings(streamSettings) - isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1") - isH3 := tlsConfig != nil && (len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3") if isH3 { dest.Network = net.Network_UDP } + if client, found := globalDialerMap[dialerConf{dest, streamSettings}]; found { + return client + } var gotlsConfig *gotls.Config @@ -80,6 +74,12 @@ func createHTTPClient(ctx context.Context, dest net.Destination, streamSettings gotlsConfig = tlsConfig.GetTLSConfig(tls.WithDestination(dest)) } + transportConfig := streamSettings.ProtocolSettings.(*Config) + var mux Multiplexing + if transportConfig.HttpMux != nil { + mux = *transportConfig.HttpMux + } + dialContext := func(ctxInner context.Context) (net.Conn, error) { conn, err := internet.DialSystem(ctxInner, dest, streamSettings.SocketSettings) if err != nil { @@ -113,56 +113,60 @@ func createHTTPClient(ctx context.Context, dest net.Destination, streamSettings MaxIncomingStreams: -1, KeepAlivePeriod: h3KeepalivePeriod, } - roundTripper := &http3.RoundTripper{ - QUICConfig: quicConfig, - TLSClientConfig: gotlsConfig, - Dial: func(ctx context.Context, addr string, tlsCfg *gotls.Config, cfg *quic.Config) (quic.EarlyConnection, error) { - conn, err := internet.DialSystem(ctx, dest, streamSettings.SocketSettings) - if err != nil { - return nil, err - } - - var udpConn net.PacketConn - var udpAddr *net.UDPAddr - - switch c := conn.(type) { - case *internet.PacketConnWrapper: - var ok bool - udpConn, ok = c.Conn.(*net.UDPConn) - if !ok { - return nil, errors.New("PacketConnWrapper does not contain a UDP connection") - } - udpAddr, err = net.ResolveUDPAddr("udp", c.Dest.String()) + roundTripper := NewMuxManager(mux, func() http.RoundTripper { + return &http3.RoundTripper{ + QUICConfig: quicConfig, + TLSClientConfig: gotlsConfig, + Dial: func(ctx context.Context, addr string, tlsCfg *gotls.Config, cfg *quic.Config) (quic.EarlyConnection, error) { + conn, err := internet.DialSystem(ctx, dest, streamSettings.SocketSettings) if err != nil { return nil, err } - case *net.UDPConn: - udpConn = c - udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String()) - if err != nil { - return nil, err - } - default: - udpConn = &internet.FakePacketConn{c} - udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String()) - if err != nil { - return nil, err + + var udpConn net.PacketConn + var udpAddr *net.UDPAddr + + switch c := conn.(type) { + case *internet.PacketConnWrapper: + var ok bool + udpConn, ok = c.Conn.(*net.UDPConn) + if !ok { + return nil, errors.New("PacketConnWrapper does not contain a UDP connection") + } + udpAddr, err = net.ResolveUDPAddr("udp", c.Dest.String()) + if err != nil { + return nil, err + } + case *net.UDPConn: + udpConn = c + udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String()) + if err != nil { + return nil, err + } + default: + udpConn = &internet.FakePacketConn{c} + udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String()) + if err != nil { + return nil, err + } } - } - return quic.DialEarly(ctx, udpConn, udpAddr, tlsCfg, cfg) - }, - } + return quic.DialEarly(ctx, udpConn, udpAddr, tlsCfg, cfg) + }, + } + }) downloadTransport = roundTripper uploadTransport = roundTripper } else if isH2 { - downloadTransport = &http2.Transport{ - DialTLSContext: func(ctxInner context.Context, network string, addr string, cfg *gotls.Config) (net.Conn, error) { - return dialContext(ctxInner) - }, - IdleConnTimeout: connIdleTimeout, - ReadIdleTimeout: h2KeepalivePeriod, - } + downloadTransport = NewMuxManager(mux, func() http.RoundTripper { + return &http2.Transport{ + DialTLSContext: func(ctxInner context.Context, network string, addr string, cfg *gotls.Config) (net.Conn, error) { + return dialContext(ctxInner) + }, + IdleConnTimeout: connIdleTimeout, + ReadIdleTimeout: h2KeepalivePeriod, + } + }) uploadTransport = downloadTransport } else { httpDialContext := func(ctxInner context.Context, network string, addr string) (net.Conn, error) { @@ -181,8 +185,8 @@ func createHTTPClient(ctx context.Context, dest net.Destination, streamSettings uploadTransport = nil } - client := DefaultDialerClient{ - transportConfig: streamSettings.ProtocolSettings.(*Config), + client := &DefaultDialerClient{ + transportConfig: transportConfig, download: &http.Client{ Transport: downloadTransport, }, @@ -195,7 +199,8 @@ func createHTTPClient(ctx context.Context, dest net.Destination, streamSettings dialUploadConn: dialContext, } - return &client + globalDialerMap[dialerConf{dest, streamSettings}] = client + return client } func init() { @@ -209,6 +214,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me transportConfiguration := streamSettings.ProtocolSettings.(*Config) tlsConfig := tls.ConfigFromStreamSettings(streamSettings) + scMaxConcurrentPosts := transportConfiguration.GetNormalizedScMaxConcurrentPosts() scMaxEachPostBytes := transportConfiguration.GetNormalizedScMaxEachPostBytes() scMinPostsIntervalMs := transportConfiguration.GetNormalizedScMinPostsIntervalMs() @@ -245,7 +251,6 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me // calls get automatically batched together into larger POST requests. // without batching, bandwidth is extremely limited. for { - chunk, err := uploadPipeReader.ReadMultiBuffer() if err != nil { break diff --git a/transport/internet/splithttp/mux.go b/transport/internet/splithttp/mux.go index 3fa1c0596920..5ec131ed4d62 100644 --- a/transport/internet/splithttp/mux.go +++ b/transport/internet/splithttp/mux.go @@ -2,114 +2,146 @@ package splithttp import ( "context" + "io" + "math/rand" + "net/http" "sync" + "sync/atomic" "time" - "github.com/xtls/xray-core/common/net" - "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/common/errors" + "github.com/xtls/xray-core/common/signal/done" ) -type muxDialerClient struct { - *DefaultDialerClient +type muxRoundTripper struct { + inner http.RoundTripper + OpenRequests atomic.Int32 leftUsage int32 expirationTime time.Time } +func (c *muxRoundTripper) RoundTrip(request *http.Request) (*http.Response, error) { + c.OpenRequests.Add(1) + done := done.New() + + go func() { + select { + case <-request.Context().Done(): + case <-done.Wait(): + } + + c.OpenRequests.Add(-1) + }() + + response, err := c.inner.RoundTrip(request) + if err != nil { + done.Close() + } + + response.Body = &bodyCloser{ReadCloser: response.Body, done: done} + return response, err +} + +type bodyCloser struct { + io.ReadCloser + done *done.Instance +} + +func (b *bodyCloser) Close() error { + b.done.Close() + return b.ReadCloser.Close() +} + type muxManager struct { sync.Mutex - config *Multiplexing - dialerClients []muxDialerClient + newClientFn func() http.RoundTripper + config Multiplexing + concurrency int32 + connections int32 + dialerClients []*muxRoundTripper } -func newMuxManager(config *Multiplexing) *muxManager { +func NewMuxManager(config Multiplexing, newClient func() http.RoundTripper) *muxManager { return &muxManager{ config: config, - dialerClients: make([]muxDialerClient, 0), + concurrency: config.GetNormalizedConcurrency().roll(), + connections: config.GetNormalizedConnections().roll(), + newClientFn: newClient, + dialerClients: make([]*muxRoundTripper, 0), } } -func (m *muxManager) getClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) *muxDialerClient { +func (m *muxManager) RoundTrip(request *http.Request) (*http.Response, error) { + client := m.GetClient(request.Context()) + return client.RoundTrip(request) +} + +func (m *muxManager) GetClient(ctx context.Context) *muxRoundTripper { m.Lock() defer m.Unlock() - if len(m.dialerClients) > 0 { - m.removeExpiredConnections() + + m.removeExpiredConnections(ctx) + + if m.connections > 0 && len(m.dialerClients) < int(m.connections) { + errors.LogDebug(ctx, "httpMux: creating client, connections=", len(m.dialerClients)) + return m.newClient() } - switch m.config.GetMode() { - case Multiplexing_PREFER_EXTISTING: - return m.dialPreferExisting(ctx, dest, streamSettings) - case Multiplexing_PREFER_NEW: - return m.dialPreferNew(ctx, dest, streamSettings) - default: - return &muxDialerClient{ - DefaultDialerClient: createHTTPClient(ctx, dest, streamSettings), - } + + if len(m.dialerClients) == 0 { + errors.LogDebug(ctx, "httpMux: creating client because dialerClients is empty, connections=", len(m.dialerClients)) + return m.newClient() } -} -func (m *muxManager) dialPreferExisting(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) *muxDialerClient { - for { + clients := make([]*muxRoundTripper, 0) + if m.concurrency > 0 { for _, client := range m.dialerClients { - if m.canReuseClient(client) { - client.leftUsage-- - return &client + openRequests := client.OpenRequests.Load() + if openRequests < m.concurrency { + clients = append(clients, client) } } - if int32(len(m.dialerClients)) >= m.config.GetMaxConnections() || m.config.GetMaxConnections() == 0 { - if streamSettings.ProtocolSettings.(*Config).GetNormalizedScMinPostsIntervalMs().From > 0 { - time.Sleep(time.Duration(streamSettings.ProtocolSettings.(*Config).GetNormalizedScMinPostsIntervalMs().roll()) * time.Millisecond) - } - continue - } - break + } else { + clients = m.dialerClients } - return m.newClient(ctx, dest, streamSettings) -} -func (m *muxManager) dialPreferNew(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) *muxDialerClient { - for { - if int32(len(m.dialerClients)) < m.config.MaxConnections || m.config.MaxConnections == 0 { - return m.newClient(ctx, dest, streamSettings) - } + if len(clients) == 0 { + errors.LogDebug(ctx, "httpMux: creating client because concurrency was hit, total clients=", len(m.dialerClients)) + return m.newClient() + } - for _, client := range m.dialerClients { - if m.canReuseClient(client) { - client.leftUsage-- - return &client - } - } - if streamSettings.ProtocolSettings.(*Config).GetNormalizedScMinPostsIntervalMs().From > 0 { - time.Sleep(time.Duration(streamSettings.ProtocolSettings.(*Config).GetNormalizedScMinPostsIntervalMs().roll()) * time.Millisecond) - } - continue + client := clients[rand.Intn(len(clients))] + if client.leftUsage > 0 { + client.leftUsage -= 1 } + return client } -func (m *muxManager) newClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) *muxDialerClient { - m.Lock() - defer m.Unlock() +func (m *muxManager) newClient() *muxRoundTripper { + leftUsage := int32(-1) + if x := m.config.GetNormalizedRequestsPerConnection().roll(); x > 0 { + leftUsage = x - 1 + } + expirationTime := time.UnixMilli(0) + if x := m.config.GetNormalizedConnectionLifetimeMs().roll(); x > 0 { + expirationTime = time.Now().Add(time.Duration(x) * time.Millisecond) + } - Client := muxDialerClient{ - DefaultDialerClient: createHTTPClient(ctx, dest, streamSettings), - leftUsage: m.config.GetNormalizedMaxConnectionConcurrency().roll(), - expirationTime: time.Now().Add(time.Duration(m.config.GetNormalizedConnectionLifetime().roll()) * time.Second), + client := &muxRoundTripper{ + inner: m.newClientFn(), + leftUsage: leftUsage, + expirationTime: expirationTime, } - m.dialerClients = append(m.dialerClients, Client) - return &Client + m.dialerClients = append(m.dialerClients, client) + return client } -func (m *muxManager) removeExpiredConnections() { - m.Lock() - defer m.Unlock() - +func (m *muxManager) removeExpiredConnections(ctx context.Context) { for i := 0; i < len(m.dialerClients); i++ { client := m.dialerClients[i] - if time.Now().After(client.expirationTime) || client.leftUsage <= 0 { + if client.leftUsage == 0 || (client.expirationTime != time.UnixMilli(0) && time.Now().After(client.expirationTime)) { + errors.LogDebug(ctx, "httpMux: removing client, leftUsage = ", client.leftUsage, ", expirationTime = ", client.expirationTime) m.dialerClients = append(m.dialerClients[:i], m.dialerClients[i+1:]...) i-- } } } - -func (m *muxManager) canReuseClient(c muxDialerClient) bool { - return c.leftUsage > 0 && time.Now().Before(c.expirationTime) -} diff --git a/transport/internet/splithttp/mux_test.go b/transport/internet/splithttp/mux_test.go new file mode 100644 index 000000000000..bef04f1e757d --- /dev/null +++ b/transport/internet/splithttp/mux_test.go @@ -0,0 +1,93 @@ +package splithttp_test + +import ( + "context" + "net/http" + "testing" + + . "github.com/xtls/xray-core/transport/internet/splithttp" +) + +type fakeRoundTripper struct{} + +func (c *fakeRoundTripper) RoundTrip(request *http.Request) (*http.Response, error) { + return nil, nil +} + +func TestConnections(t *testing.T) { + config := Multiplexing{ + Connections: &RandRangeConfig{From: 4, To: 4}, + } + + mux := NewMuxManager(config, func() http.RoundTripper { + return &fakeRoundTripper{} + }) + + clients := make(map[interface{}]struct{}) + for i := 0; i < 8; i++ { + clients[mux.GetClient(context.Background())] = struct{}{} + } + + if len(clients) != 4 { + t.Error("did not get 4 distinct clients, got ", len(clients)) + } +} + +func TestRequestsPerConnection(t *testing.T) { + config := Multiplexing{ + RequestsPerConnection: &RandRangeConfig{From: 2, To: 2}, + } + + mux := NewMuxManager(config, func() http.RoundTripper { + return &fakeRoundTripper{} + }) + + clients := make(map[interface{}]struct{}) + for i := 0; i < 64; i++ { + clients[mux.GetClient(context.Background())] = struct{}{} + } + + if len(clients) != 32 { + t.Error("did not get 32 distinct clients, got ", len(clients)) + } +} + +func TestConcurrency(t *testing.T) { + config := Multiplexing{ + Concurrency: &RandRangeConfig{From: 2, To: 2}, + } + + mux := NewMuxManager(config, func() http.RoundTripper { + return &fakeRoundTripper{} + }) + + clients := make(map[interface{}]struct{}) + for i := 0; i < 64; i++ { + client := mux.GetClient(context.Background()) + client.OpenRequests.Add(1) + clients[client] = struct{}{} + } + + if len(clients) != 32 { + t.Error("did not get 32 distinct clients, got ", len(clients)) + } +} + +func TestDefault(t *testing.T) { + config := Multiplexing{} + + mux := NewMuxManager(config, func() http.RoundTripper { + return &fakeRoundTripper{} + }) + + clients := make(map[interface{}]struct{}) + for i := 0; i < 64; i++ { + client := mux.GetClient(context.Background()) + client.OpenRequests.Add(1) + clients[client] = struct{}{} + } + + if len(clients) != 1 { + t.Error("did not get 1 distinct clients, got ", len(clients)) + } +} From b13dc68d662258febe7df8c93a9868e56a12f666 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Fri, 13 Sep 2024 07:43:26 -0500 Subject: [PATCH 04/11] make mux manager work at the virtual connection level again --- transport/internet/splithttp/client.go | 7 +- transport/internet/splithttp/connection.go | 5 + transport/internet/splithttp/dialer.go | 161 +++++++++++---------- transport/internet/splithttp/mux.go | 92 ++++-------- transport/internet/splithttp/mux_test.go | 21 +-- 5 files changed, 127 insertions(+), 159 deletions(-) diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index e491ef3ea383..8f3f90c6aaeb 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -29,8 +29,7 @@ type DialerClient interface { // implements splithttp.DialerClient in terms of direct network connections type DefaultDialerClient struct { transportConfig *Config - download *http.Client - upload *http.Client + client *http.Client isH2 bool isH3 bool // pool of net.Conn, created using dialUploadConn @@ -79,7 +78,7 @@ func (c *DefaultDialerClient) OpenDownload(ctx context.Context, baseURL string) req.Header = c.transportConfig.GetRequestHeader() - response, err := c.download.Do(req) + response, err := c.client.Do(req) gotConn.Close() if err != nil { errors.LogInfoInner(ctx, err, "failed to send download http request") @@ -137,7 +136,7 @@ func (c *DefaultDialerClient) SendUploadRequest(ctx context.Context, url string, req.Header = c.transportConfig.GetRequestHeader() if c.isH2 || c.isH3 { - resp, err := c.upload.Do(req) + resp, err := c.client.Do(req) if err != nil { return err } diff --git a/transport/internet/splithttp/connection.go b/transport/internet/splithttp/connection.go index 697381d4252c..613e1f36b4f5 100644 --- a/transport/internet/splithttp/connection.go +++ b/transport/internet/splithttp/connection.go @@ -11,6 +11,7 @@ type splitConn struct { reader io.ReadCloser remoteAddr net.Addr localAddr net.Addr + onClose func() } func (c *splitConn) Write(b []byte) (int, error) { @@ -22,6 +23,10 @@ func (c *splitConn) Read(b []byte) (int, error) { } func (c *splitConn) Close() error { + if c.onClose != nil { + c.onClose() + } + err := c.writer.Close() err2 := c.reader.Close() if err != nil { diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index e820cfd5ccfc..451ceda04464 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -41,32 +41,51 @@ type dialerConf struct { } var ( - globalDialerMap map[dialerConf]DialerClient + globalDialerMap map[dialerConf]*muxManager globalDialerAccess sync.Mutex ) -func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) DialerClient { +func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (DialerClient, *muxResource) { if browser_dialer.HasBrowserDialer() { - return &BrowserDialerClient{} + return &BrowserDialerClient{}, nil } - tlsConfig := tls.ConfigFromStreamSettings(streamSettings) - isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1") - isH3 := tlsConfig != nil && (len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3") - globalDialerAccess.Lock() defer globalDialerAccess.Unlock() if globalDialerMap == nil { - globalDialerMap = make(map[dialerConf]DialerClient) + globalDialerMap = make(map[dialerConf]*muxManager) + } + + key := dialerConf{dest, streamSettings} + + muxManager, found := globalDialerMap[key] + + if !found { + transportConfig := streamSettings.ProtocolSettings.(*Config) + var mux Multiplexing + if transportConfig.HttpMux != nil { + mux = *transportConfig.HttpMux + } + + muxManager = NewMuxManager(mux, func() interface{} { + return createHTTPClient(dest, streamSettings) + }) + globalDialerMap[key] = muxManager } + res := muxManager.GetResource(ctx) + return res.Resource.(DialerClient), res +} + +func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStreamConfig) DialerClient { + tlsConfig := tls.ConfigFromStreamSettings(streamSettings) + isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1") + isH3 := tlsConfig != nil && (len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3") + if isH3 { dest.Network = net.Network_UDP } - if client, found := globalDialerMap[dialerConf{dest, streamSettings}]; found { - return client - } var gotlsConfig *gotls.Config @@ -75,10 +94,6 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in } transportConfig := streamSettings.ProtocolSettings.(*Config) - var mux Multiplexing - if transportConfig.HttpMux != nil { - mux = *transportConfig.HttpMux - } dialContext := func(ctxInner context.Context) (net.Conn, error) { conn, err := internet.DialSystem(ctxInner, dest, streamSettings.SocketSettings) @@ -100,8 +115,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in return conn, nil } - var downloadTransport http.RoundTripper - var uploadTransport http.RoundTripper + var transport http.RoundTripper if isH3 { quicConfig := &quic.Config{ @@ -113,67 +127,60 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in MaxIncomingStreams: -1, KeepAlivePeriod: h3KeepalivePeriod, } - roundTripper := NewMuxManager(mux, func() http.RoundTripper { - return &http3.RoundTripper{ - QUICConfig: quicConfig, - TLSClientConfig: gotlsConfig, - Dial: func(ctx context.Context, addr string, tlsCfg *gotls.Config, cfg *quic.Config) (quic.EarlyConnection, error) { - conn, err := internet.DialSystem(ctx, dest, streamSettings.SocketSettings) + transport = &http3.RoundTripper{ + QUICConfig: quicConfig, + TLSClientConfig: gotlsConfig, + Dial: func(ctx context.Context, addr string, tlsCfg *gotls.Config, cfg *quic.Config) (quic.EarlyConnection, error) { + conn, err := internet.DialSystem(ctx, dest, streamSettings.SocketSettings) + if err != nil { + return nil, err + } + + var udpConn net.PacketConn + var udpAddr *net.UDPAddr + + switch c := conn.(type) { + case *internet.PacketConnWrapper: + var ok bool + udpConn, ok = c.Conn.(*net.UDPConn) + if !ok { + return nil, errors.New("PacketConnWrapper does not contain a UDP connection") + } + udpAddr, err = net.ResolveUDPAddr("udp", c.Dest.String()) if err != nil { return nil, err } - - var udpConn net.PacketConn - var udpAddr *net.UDPAddr - - switch c := conn.(type) { - case *internet.PacketConnWrapper: - var ok bool - udpConn, ok = c.Conn.(*net.UDPConn) - if !ok { - return nil, errors.New("PacketConnWrapper does not contain a UDP connection") - } - udpAddr, err = net.ResolveUDPAddr("udp", c.Dest.String()) - if err != nil { - return nil, err - } - case *net.UDPConn: - udpConn = c - udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String()) - if err != nil { - return nil, err - } - default: - udpConn = &internet.FakePacketConn{c} - udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String()) - if err != nil { - return nil, err - } + case *net.UDPConn: + udpConn = c + udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String()) + if err != nil { + return nil, err } + default: + udpConn = &internet.FakePacketConn{c} + udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String()) + if err != nil { + return nil, err + } + } - return quic.DialEarly(ctx, udpConn, udpAddr, tlsCfg, cfg) - }, - } - }) - downloadTransport = roundTripper - uploadTransport = roundTripper + return quic.DialEarly(ctx, udpConn, udpAddr, tlsCfg, cfg) + }, + } } else if isH2 { - downloadTransport = NewMuxManager(mux, func() http.RoundTripper { - return &http2.Transport{ - DialTLSContext: func(ctxInner context.Context, network string, addr string, cfg *gotls.Config) (net.Conn, error) { - return dialContext(ctxInner) - }, - IdleConnTimeout: connIdleTimeout, - ReadIdleTimeout: h2KeepalivePeriod, - } - }) - uploadTransport = downloadTransport + transport = &http2.Transport{ + DialTLSContext: func(ctxInner context.Context, network string, addr string, cfg *gotls.Config) (net.Conn, error) { + return dialContext(ctxInner) + }, + IdleConnTimeout: connIdleTimeout, + ReadIdleTimeout: h2KeepalivePeriod, + } } else { httpDialContext := func(ctxInner context.Context, network string, addr string) (net.Conn, error) { return dialContext(ctxInner) } - downloadTransport = &http.Transport{ + transport = &http.Transport{ DialTLSContext: httpDialContext, DialContext: httpDialContext, IdleConnTimeout: connIdleTimeout, @@ -181,17 +188,12 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in // http.Client and our custom dial context. DisableKeepAlives: true, } - // we use uploadRawPool for that - uploadTransport = nil } client := &DefaultDialerClient{ transportConfig: transportConfig, - download: &http.Client{ - Transport: downloadTransport, - }, - upload: &http.Client{ - Transport: uploadTransport, + client: &http.Client{ + Transport: transport, }, isH2: isH2, isH3: isH3, @@ -199,7 +201,6 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in dialUploadConn: dialContext, } - globalDialerMap[dialerConf{dest, streamSettings}] = client return client } @@ -233,7 +234,10 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me requestURL.Path = transportConfiguration.GetNormalizedPath() + sessionIdUuid.String() requestURL.RawQuery = transportConfiguration.GetNormalizedQuery() - httpClient := getHTTPClient(ctx, dest, streamSettings) + httpClient, muxResource := getHTTPClient(ctx, dest, streamSettings) + if muxResource != nil { + muxResource.OpenRequests.Add(1) + } maxUploadSize := scMaxEachPostBytes.roll() // WithSizeLimit(0) will still allow single bytes to pass, and a lot of @@ -312,6 +316,11 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me reader: reader, remoteAddr: remoteAddr, localAddr: localAddr, + onClose: func() { + if muxResource != nil { + muxResource.OpenRequests.Add(-1) + } + }, } return stat.Connection(&conn), nil diff --git a/transport/internet/splithttp/mux.go b/transport/internet/splithttp/mux.go index 5ec131ed4d62..5bf48fd5ac9a 100644 --- a/transport/internet/splithttp/mux.go +++ b/transport/internet/splithttp/mux.go @@ -2,111 +2,71 @@ package splithttp import ( "context" - "io" "math/rand" - "net/http" "sync" "sync/atomic" "time" "github.com/xtls/xray-core/common/errors" - "github.com/xtls/xray-core/common/signal/done" ) -type muxRoundTripper struct { - inner http.RoundTripper +type muxResource struct { + Resource interface{} OpenRequests atomic.Int32 leftUsage int32 expirationTime time.Time } -func (c *muxRoundTripper) RoundTrip(request *http.Request) (*http.Response, error) { - c.OpenRequests.Add(1) - done := done.New() - - go func() { - select { - case <-request.Context().Done(): - case <-done.Wait(): - } - - c.OpenRequests.Add(-1) - }() - - response, err := c.inner.RoundTrip(request) - if err != nil { - done.Close() - } - - response.Body = &bodyCloser{ReadCloser: response.Body, done: done} - return response, err -} - -type bodyCloser struct { - io.ReadCloser - done *done.Instance -} - -func (b *bodyCloser) Close() error { - b.done.Close() - return b.ReadCloser.Close() -} - type muxManager struct { sync.Mutex - newClientFn func() http.RoundTripper + newResourceFn func() interface{} config Multiplexing concurrency int32 connections int32 - dialerClients []*muxRoundTripper + instances []*muxResource } -func NewMuxManager(config Multiplexing, newClient func() http.RoundTripper) *muxManager { +func NewMuxManager(config Multiplexing, newResource func() interface{}) *muxManager { return &muxManager{ config: config, concurrency: config.GetNormalizedConcurrency().roll(), connections: config.GetNormalizedConnections().roll(), - newClientFn: newClient, - dialerClients: make([]*muxRoundTripper, 0), + newResourceFn: newResource, + instances: make([]*muxResource, 0), } } -func (m *muxManager) RoundTrip(request *http.Request) (*http.Response, error) { - client := m.GetClient(request.Context()) - return client.RoundTrip(request) -} - -func (m *muxManager) GetClient(ctx context.Context) *muxRoundTripper { +func (m *muxManager) GetResource(ctx context.Context) *muxResource { m.Lock() defer m.Unlock() m.removeExpiredConnections(ctx) - if m.connections > 0 && len(m.dialerClients) < int(m.connections) { - errors.LogDebug(ctx, "httpMux: creating client, connections=", len(m.dialerClients)) - return m.newClient() + if m.connections > 0 && len(m.instances) < int(m.connections) { + errors.LogDebug(ctx, "httpMux: creating client, connections=", len(m.instances)) + return m.newResource() } - if len(m.dialerClients) == 0 { - errors.LogDebug(ctx, "httpMux: creating client because dialerClients is empty, connections=", len(m.dialerClients)) - return m.newClient() + if len(m.instances) == 0 { + errors.LogDebug(ctx, "httpMux: creating client because instances is empty, connections=", len(m.instances)) + return m.newResource() } - clients := make([]*muxRoundTripper, 0) + clients := make([]*muxResource, 0) if m.concurrency > 0 { - for _, client := range m.dialerClients { + for _, client := range m.instances { openRequests := client.OpenRequests.Load() if openRequests < m.concurrency { clients = append(clients, client) } } } else { - clients = m.dialerClients + clients = m.instances } if len(clients) == 0 { - errors.LogDebug(ctx, "httpMux: creating client because concurrency was hit, total clients=", len(m.dialerClients)) - return m.newClient() + errors.LogDebug(ctx, "httpMux: creating client because concurrency was hit, total clients=", len(m.instances)) + return m.newResource() } client := clients[rand.Intn(len(clients))] @@ -116,7 +76,7 @@ func (m *muxManager) GetClient(ctx context.Context) *muxRoundTripper { return client } -func (m *muxManager) newClient() *muxRoundTripper { +func (m *muxManager) newResource() *muxResource { leftUsage := int32(-1) if x := m.config.GetNormalizedRequestsPerConnection().roll(); x > 0 { leftUsage = x - 1 @@ -126,21 +86,21 @@ func (m *muxManager) newClient() *muxRoundTripper { expirationTime = time.Now().Add(time.Duration(x) * time.Millisecond) } - client := &muxRoundTripper{ - inner: m.newClientFn(), + client := &muxResource{ + Resource: m.newResourceFn(), leftUsage: leftUsage, expirationTime: expirationTime, } - m.dialerClients = append(m.dialerClients, client) + m.instances = append(m.instances, client) return client } func (m *muxManager) removeExpiredConnections(ctx context.Context) { - for i := 0; i < len(m.dialerClients); i++ { - client := m.dialerClients[i] + for i := 0; i < len(m.instances); i++ { + client := m.instances[i] if client.leftUsage == 0 || (client.expirationTime != time.UnixMilli(0) && time.Now().After(client.expirationTime)) { errors.LogDebug(ctx, "httpMux: removing client, leftUsage = ", client.leftUsage, ", expirationTime = ", client.expirationTime) - m.dialerClients = append(m.dialerClients[:i], m.dialerClients[i+1:]...) + m.instances = append(m.instances[:i], m.instances[i+1:]...) i-- } } diff --git a/transport/internet/splithttp/mux_test.go b/transport/internet/splithttp/mux_test.go index bef04f1e757d..12a2ddea9890 100644 --- a/transport/internet/splithttp/mux_test.go +++ b/transport/internet/splithttp/mux_test.go @@ -2,7 +2,6 @@ package splithttp_test import ( "context" - "net/http" "testing" . "github.com/xtls/xray-core/transport/internet/splithttp" @@ -10,22 +9,18 @@ import ( type fakeRoundTripper struct{} -func (c *fakeRoundTripper) RoundTrip(request *http.Request) (*http.Response, error) { - return nil, nil -} - func TestConnections(t *testing.T) { config := Multiplexing{ Connections: &RandRangeConfig{From: 4, To: 4}, } - mux := NewMuxManager(config, func() http.RoundTripper { + mux := NewMuxManager(config, func() interface{} { return &fakeRoundTripper{} }) clients := make(map[interface{}]struct{}) for i := 0; i < 8; i++ { - clients[mux.GetClient(context.Background())] = struct{}{} + clients[mux.GetResource(context.Background())] = struct{}{} } if len(clients) != 4 { @@ -38,13 +33,13 @@ func TestRequestsPerConnection(t *testing.T) { RequestsPerConnection: &RandRangeConfig{From: 2, To: 2}, } - mux := NewMuxManager(config, func() http.RoundTripper { + mux := NewMuxManager(config, func() interface{} { return &fakeRoundTripper{} }) clients := make(map[interface{}]struct{}) for i := 0; i < 64; i++ { - clients[mux.GetClient(context.Background())] = struct{}{} + clients[mux.GetResource(context.Background())] = struct{}{} } if len(clients) != 32 { @@ -57,13 +52,13 @@ func TestConcurrency(t *testing.T) { Concurrency: &RandRangeConfig{From: 2, To: 2}, } - mux := NewMuxManager(config, func() http.RoundTripper { + mux := NewMuxManager(config, func() interface{} { return &fakeRoundTripper{} }) clients := make(map[interface{}]struct{}) for i := 0; i < 64; i++ { - client := mux.GetClient(context.Background()) + client := mux.GetResource(context.Background()) client.OpenRequests.Add(1) clients[client] = struct{}{} } @@ -76,13 +71,13 @@ func TestConcurrency(t *testing.T) { func TestDefault(t *testing.T) { config := Multiplexing{} - mux := NewMuxManager(config, func() http.RoundTripper { + mux := NewMuxManager(config, func() interface{} { return &fakeRoundTripper{} }) clients := make(map[interface{}]struct{}) for i := 0; i < 64; i++ { - client := mux.GetClient(context.Background()) + client := mux.GetResource(context.Background()) client.OpenRequests.Add(1) clients[client] = struct{}{} } From 4804a9c22cdeb009dafda2c692001e008b39c35e Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Fri, 13 Sep 2024 08:09:51 -0500 Subject: [PATCH 05/11] minimize diff and rename some params --- infra/conf/transport_internet.go | 16 ++--- transport/internet/splithttp/config.go | 9 ++- transport/internet/splithttp/config.pb.go | 80 +++++++++++------------ transport/internet/splithttp/config.proto | 2 +- transport/internet/splithttp/dialer.go | 16 ++--- transport/internet/splithttp/mux.go | 2 +- transport/internet/splithttp/mux_test.go | 4 +- 7 files changed, 65 insertions(+), 64 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 44c1b940d825..b3fe9b3565eb 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -235,10 +235,10 @@ type SplitHTTPConfig struct { } type SplitHTTPMux struct { - RequestsPerConnection *Int32Range `json:"requestsPerConnection"` - ConnectionLifetimeMs *Int32Range `json:"connectionLifetimeMs"` - Connections *Int32Range `json:"connections"` - Concurrency *Int32Range `json:"concurrency"` + MaxUses *Int32Range `json:"maxUses"` + ConnectionLifetimeMs *Int32Range `json:"connectionLifetimeMs"` + Connections *Int32Range `json:"connections"` + Concurrency *Int32Range `json:"concurrency"` } func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig { @@ -265,10 +265,10 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { // Multiplexing config muxProtobuf := splithttp.Multiplexing{ - RequestsPerConnection: splithttpNewRandRangeConfig(c.HttpMux.RequestsPerConnection), - ConnectionLifetimeMs: splithttpNewRandRangeConfig(c.HttpMux.ConnectionLifetimeMs), - Connections: splithttpNewRandRangeConfig(c.HttpMux.Connections), - Concurrency: splithttpNewRandRangeConfig(c.HttpMux.Concurrency), + MaxUses: splithttpNewRandRangeConfig(c.HttpMux.MaxUses), + ConnectionLifetimeMs: splithttpNewRandRangeConfig(c.HttpMux.ConnectionLifetimeMs), + Connections: splithttpNewRandRangeConfig(c.HttpMux.Connections), + Concurrency: splithttpNewRandRangeConfig(c.HttpMux.Concurrency), } config := &splithttp.Config{ diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 5ff20b2c5bf3..291988939dd5 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -53,6 +53,7 @@ func (c *Config) GetRequestHeader() http.Header { return header } + func (c *Config) WriteResponseHeader(writer http.ResponseWriter) { paddingLen := c.GetNormalizedXPaddingBytes().roll() if paddingLen > 0 { @@ -78,8 +79,10 @@ func (c *Config) GetNormalizedScMaxEachPostBytes() RandRangeConfig { To: 1000000, } } + return *c.ScMaxEachPostBytes } + func (c *Config) GetNormalizedScMinPostsIntervalMs() RandRangeConfig { if c.ScMinPostsIntervalMs == nil || c.ScMinPostsIntervalMs.To == 0 { return RandRangeConfig{ @@ -102,15 +105,15 @@ func (c *Config) GetNormalizedXPaddingBytes() RandRangeConfig { return *c.XPaddingBytes } -func (m *Multiplexing) GetNormalizedRequestsPerConnection() RandRangeConfig { - if m.RequestsPerConnection == nil { +func (m *Multiplexing) GetNormalizedMaxUses() RandRangeConfig { + if m.MaxUses == nil { return RandRangeConfig{ From: 0, To: 0, } } - return *m.RequestsPerConnection + return *m.MaxUses } func (m *Multiplexing) GetNormalizedConnectionLifetimeMs() RandRangeConfig { diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 53db29b4f3f5..23eadc207302 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -191,10 +191,10 @@ type Multiplexing struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RequestsPerConnection *RandRangeConfig `protobuf:"bytes,4,opt,name=requestsPerConnection,proto3" json:"requestsPerConnection,omitempty"` - ConnectionLifetimeMs *RandRangeConfig `protobuf:"bytes,5,opt,name=connectionLifetimeMs,proto3" json:"connectionLifetimeMs,omitempty"` - Connections *RandRangeConfig `protobuf:"bytes,6,opt,name=connections,proto3" json:"connections,omitempty"` - Concurrency *RandRangeConfig `protobuf:"bytes,7,opt,name=concurrency,proto3" json:"concurrency,omitempty"` + MaxUses *RandRangeConfig `protobuf:"bytes,4,opt,name=maxUses,proto3" json:"maxUses,omitempty"` + ConnectionLifetimeMs *RandRangeConfig `protobuf:"bytes,5,opt,name=connectionLifetimeMs,proto3" json:"connectionLifetimeMs,omitempty"` + Connections *RandRangeConfig `protobuf:"bytes,6,opt,name=connections,proto3" json:"connections,omitempty"` + Concurrency *RandRangeConfig `protobuf:"bytes,7,opt,name=concurrency,proto3" json:"concurrency,omitempty"` } func (x *Multiplexing) Reset() { @@ -229,9 +229,9 @@ func (*Multiplexing) Descriptor() ([]byte, []int) { return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{2} } -func (x *Multiplexing) GetRequestsPerConnection() *RandRangeConfig { +func (x *Multiplexing) GetMaxUses() *RandRangeConfig { if x != nil { - return x.RequestsPerConnection + return x.MaxUses } return nil } @@ -311,41 +311,39 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, - 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0x8c, 0x03, - 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x68, - 0x0a, 0x15, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x50, 0x65, 0x72, 0x43, 0x6f, 0x6e, - 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 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, 0x15, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x50, 0x65, 0x72, 0x43, 0x6f, - 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x66, 0x0a, 0x14, 0x63, 0x6f, 0x6e, 0x6e, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, + 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0xf0, 0x02, + 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x4c, + 0x0a, 0x07, 0x6d, 0x61, 0x78, 0x55, 0x73, 0x65, 0x73, 0x18, 0x04, 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, 0x07, 0x6d, 0x61, 0x78, 0x55, 0x73, 0x65, 0x73, 0x12, 0x66, 0x0a, 0x14, + 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, + 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x05, 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, 0x14, + 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, + 0x6d, 0x65, 0x4d, 0x73, 0x12, 0x54, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0x06, 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, 0x0b, 0x63, + 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x54, 0x0a, 0x0b, 0x63, 0x6f, + 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x07, 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, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, + 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 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, 0x14, 0x63, 0x6f, 0x6e, 0x6e, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, - 0x12, 0x54, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, - 0x06, 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, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x54, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x07, 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, - 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x42, 0x85, 0x01, 0x0a, - 0x25, 0x63, 0x6f, 0x6d, 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, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, - 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, - 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, - 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, + 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, + 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, + 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -374,7 +372,7 @@ 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.httpMux:type_name -> xray.transport.internet.splithttp.Multiplexing - 1, // 6: xray.transport.internet.splithttp.Multiplexing.requestsPerConnection:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 6: xray.transport.internet.splithttp.Multiplexing.maxUses:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 7: xray.transport.internet.splithttp.Multiplexing.connectionLifetimeMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 8: xray.transport.internet.splithttp.Multiplexing.connections:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 9: xray.transport.internet.splithttp.Multiplexing.concurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 9f969ca2b5bd..39c72dab0090 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -24,7 +24,7 @@ message RandRangeConfig { } message Multiplexing { - RandRangeConfig requestsPerConnection = 4; + RandRangeConfig maxUses = 4; RandRangeConfig connectionLifetimeMs = 5; RandRangeConfig connections = 6; RandRangeConfig concurrency = 7; diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 35d934177dfc..200fd9c30f81 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -235,9 +235,6 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me requestURL.RawQuery = transportConfiguration.GetNormalizedQuery() httpClient, muxResource := getHTTPClient(ctx, dest, streamSettings) - if muxResource != nil { - muxResource.OpenRequests.Add(1) - } maxUploadSize := scMaxEachPostBytes.roll() // WithSizeLimit(0) will still allow single bytes to pass, and a lot of @@ -245,7 +242,15 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me // uploadWriter wrapper, exact size limits can be enforced uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize - 1)) + if muxResource != nil { + muxResource.OpenRequests.Add(1) + } + go func() { + if muxResource != nil { + defer muxResource.OpenRequests.Add(-1) + } + requestsLimiter := semaphore.New(int(scMaxConcurrentPosts.roll())) var requestCounter int64 @@ -314,11 +319,6 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me reader: reader, remoteAddr: remoteAddr, localAddr: localAddr, - onClose: func() { - if muxResource != nil { - muxResource.OpenRequests.Add(-1) - } - }, } return stat.Connection(&conn), nil diff --git a/transport/internet/splithttp/mux.go b/transport/internet/splithttp/mux.go index 5bf48fd5ac9a..04db5f10fbb0 100644 --- a/transport/internet/splithttp/mux.go +++ b/transport/internet/splithttp/mux.go @@ -78,7 +78,7 @@ func (m *muxManager) GetResource(ctx context.Context) *muxResource { func (m *muxManager) newResource() *muxResource { leftUsage := int32(-1) - if x := m.config.GetNormalizedRequestsPerConnection().roll(); x > 0 { + if x := m.config.GetNormalizedMaxUses().roll(); x > 0 { leftUsage = x - 1 } expirationTime := time.UnixMilli(0) diff --git a/transport/internet/splithttp/mux_test.go b/transport/internet/splithttp/mux_test.go index 12a2ddea9890..e462d7ff6811 100644 --- a/transport/internet/splithttp/mux_test.go +++ b/transport/internet/splithttp/mux_test.go @@ -28,9 +28,9 @@ func TestConnections(t *testing.T) { } } -func TestRequestsPerConnection(t *testing.T) { +func TestMaxUses(t *testing.T) { config := Multiplexing{ - RequestsPerConnection: &RandRangeConfig{From: 2, To: 2}, + MaxUses: &RandRangeConfig{From: 2, To: 2}, } mux := NewMuxManager(config, func() interface{} { From 8fb672bb1ae1b0b5873f7c0098464edc55be0fb8 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Fri, 13 Sep 2024 09:08:26 -0500 Subject: [PATCH 06/11] remove unnecessary locking --- transport/internet/splithttp/mux.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/transport/internet/splithttp/mux.go b/transport/internet/splithttp/mux.go index 04db5f10fbb0..fa4ed429b6d2 100644 --- a/transport/internet/splithttp/mux.go +++ b/transport/internet/splithttp/mux.go @@ -3,7 +3,6 @@ package splithttp import ( "context" "math/rand" - "sync" "sync/atomic" "time" @@ -18,7 +17,6 @@ type muxResource struct { } type muxManager struct { - sync.Mutex newResourceFn func() interface{} config Multiplexing concurrency int32 @@ -37,9 +35,6 @@ func NewMuxManager(config Multiplexing, newResource func() interface{}) *muxMana } func (m *muxManager) GetResource(ctx context.Context) *muxResource { - m.Lock() - defer m.Unlock() - m.removeExpiredConnections(ctx) if m.connections > 0 && len(m.instances) < int(m.connections) { From 3c31c7a8edb57c4590e1529f74e9d1f732e252cf Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sun, 15 Sep 2024 10:45:49 -0500 Subject: [PATCH 07/11] renaming --- infra/conf/transport_internet.go | 14 +-- transport/internet/splithttp/config.go | 6 +- transport/internet/splithttp/config.pb.go | 108 +++++++++++----------- transport/internet/splithttp/config.proto | 4 +- transport/internet/splithttp/dialer.go | 4 +- transport/internet/splithttp/mux.go | 10 +- transport/internet/splithttp/mux_test.go | 4 +- 7 files changed, 76 insertions(+), 74 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index b3fe9b3565eb..15dc15afde84 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -231,11 +231,11 @@ type SplitHTTPConfig struct { ScMinPostsIntervalMs *Int32Range `json:"scMinPostsIntervalMs"` NoSSEHeader bool `json:"noSSEHeader"` XPaddingBytes *Int32Range `json:"xPaddingBytes"` - HttpMux SplitHTTPMux `json:"httpMux"` + HttpDemux SplitHTTPMux `json:"httpDemux"` } type SplitHTTPMux struct { - MaxUses *Int32Range `json:"maxUses"` + ConnectionReuseTimes *Int32Range `json:"connectionReuseTimes"` ConnectionLifetimeMs *Int32Range `json:"connectionLifetimeMs"` Connections *Int32Range `json:"connections"` Concurrency *Int32Range `json:"concurrency"` @@ -265,10 +265,10 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { // Multiplexing config muxProtobuf := splithttp.Multiplexing{ - MaxUses: splithttpNewRandRangeConfig(c.HttpMux.MaxUses), - ConnectionLifetimeMs: splithttpNewRandRangeConfig(c.HttpMux.ConnectionLifetimeMs), - Connections: splithttpNewRandRangeConfig(c.HttpMux.Connections), - Concurrency: splithttpNewRandRangeConfig(c.HttpMux.Concurrency), + ConnectionReuseTimes: splithttpNewRandRangeConfig(c.HttpDemux.ConnectionReuseTimes), + ConnectionLifetimeMs: splithttpNewRandRangeConfig(c.HttpDemux.ConnectionLifetimeMs), + Connections: splithttpNewRandRangeConfig(c.HttpDemux.Connections), + Concurrency: splithttpNewRandRangeConfig(c.HttpDemux.Concurrency), } config := &splithttp.Config{ @@ -280,7 +280,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { ScMinPostsIntervalMs: splithttpNewRandRangeConfig(c.ScMinPostsIntervalMs), NoSSEHeader: c.NoSSEHeader, XPaddingBytes: splithttpNewRandRangeConfig(c.XPaddingBytes), - HttpMux: &muxProtobuf, + HttpDemux: &muxProtobuf, } return config, nil } diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 291988939dd5..f931d6bf4af5 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -105,15 +105,15 @@ func (c *Config) GetNormalizedXPaddingBytes() RandRangeConfig { return *c.XPaddingBytes } -func (m *Multiplexing) GetNormalizedMaxUses() RandRangeConfig { - if m.MaxUses == nil { +func (m *Multiplexing) GetNormalizedConnectionReuseTimes() RandRangeConfig { + if m.ConnectionReuseTimes == nil { return RandRangeConfig{ From: 0, To: 0, } } - return *m.MaxUses + return *m.ConnectionReuseTimes } func (m *Multiplexing) GetNormalizedConnectionLifetimeMs() RandRangeConfig { diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 23eadc207302..3e8fa9d8c426 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -33,7 +33,7 @@ type Config struct { ScMinPostsIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` NoSSEHeader bool `protobuf:"varint,7,opt,name=noSSEHeader,proto3" json:"noSSEHeader,omitempty"` XPaddingBytes *RandRangeConfig `protobuf:"bytes,8,opt,name=xPaddingBytes,proto3" json:"xPaddingBytes,omitempty"` - HttpMux *Multiplexing `protobuf:"bytes,9,opt,name=httpMux,proto3" json:"httpMux,omitempty"` + HttpDemux *Multiplexing `protobuf:"bytes,9,opt,name=httpDemux,proto3" json:"httpDemux,omitempty"` } func (x *Config) Reset() { @@ -124,9 +124,9 @@ func (x *Config) GetXPaddingBytes() *RandRangeConfig { return nil } -func (x *Config) GetHttpMux() *Multiplexing { +func (x *Config) GetHttpDemux() *Multiplexing { if x != nil { - return x.HttpMux + return x.HttpDemux } return nil } @@ -191,7 +191,7 @@ type Multiplexing struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - MaxUses *RandRangeConfig `protobuf:"bytes,4,opt,name=maxUses,proto3" json:"maxUses,omitempty"` + ConnectionReuseTimes *RandRangeConfig `protobuf:"bytes,4,opt,name=connectionReuseTimes,proto3" json:"connectionReuseTimes,omitempty"` ConnectionLifetimeMs *RandRangeConfig `protobuf:"bytes,5,opt,name=connectionLifetimeMs,proto3" json:"connectionLifetimeMs,omitempty"` Connections *RandRangeConfig `protobuf:"bytes,6,opt,name=connections,proto3" json:"connections,omitempty"` Concurrency *RandRangeConfig `protobuf:"bytes,7,opt,name=concurrency,proto3" json:"concurrency,omitempty"` @@ -229,9 +229,9 @@ func (*Multiplexing) Descriptor() ([]byte, []int) { return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{2} } -func (x *Multiplexing) GetMaxUses() *RandRangeConfig { +func (x *Multiplexing) GetConnectionReuseTimes() *RandRangeConfig { if x != nil { - return x.MaxUses + return x.ConnectionReuseTimes } return nil } @@ -264,7 +264,7 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 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, 0x22, 0xb5, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xb9, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, @@ -300,50 +300,52 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 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, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, - 0x12, 0x49, 0x0a, 0x07, 0x68, 0x74, 0x74, 0x70, 0x4d, 0x75, 0x78, 0x18, 0x09, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x2f, 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, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, - 0x6e, 0x67, 0x52, 0x07, 0x68, 0x74, 0x74, 0x70, 0x4d, 0x75, 0x78, 0x1a, 0x39, 0x0a, 0x0b, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, - 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, - 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, - 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0xf0, 0x02, - 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x4c, - 0x0a, 0x07, 0x6d, 0x61, 0x78, 0x55, 0x73, 0x65, 0x73, 0x18, 0x04, 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, 0x07, 0x6d, 0x61, 0x78, 0x55, 0x73, 0x65, 0x73, 0x12, 0x66, 0x0a, 0x14, - 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, - 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x05, 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, 0x14, - 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, - 0x6d, 0x65, 0x4d, 0x73, 0x12, 0x54, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x18, 0x06, 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, 0x0b, 0x63, - 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x54, 0x0a, 0x0b, 0x63, 0x6f, - 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x07, 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, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, - 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 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, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, - 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, - 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, - 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x4d, 0x0a, 0x09, 0x68, 0x74, 0x74, 0x70, 0x44, 0x65, 0x6d, 0x75, 0x78, 0x18, 0x09, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x2f, 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, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, + 0x78, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x68, 0x74, 0x74, 0x70, 0x44, 0x65, 0x6d, 0x75, 0x78, 0x1a, + 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, + 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, + 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, + 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, + 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, + 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, + 0x6f, 0x22, 0x8a, 0x03, 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, + 0x6e, 0x67, 0x12, 0x66, 0x0a, 0x14, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x04, 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, 0x14, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x66, 0x0a, 0x14, 0x63, 0x6f, + 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, + 0x4d, 0x73, 0x18, 0x05, 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, 0x14, 0x63, 0x6f, + 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, + 0x4d, 0x73, 0x12, 0x54, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x06, 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, 0x0b, 0x63, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x54, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x63, + 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x07, 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, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x42, 0x85, + 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 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, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, + 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, + 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, + 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -371,8 +373,8 @@ var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ 1, // 2: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig 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.httpMux:type_name -> xray.transport.internet.splithttp.Multiplexing - 1, // 6: xray.transport.internet.splithttp.Multiplexing.maxUses:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 2, // 5: xray.transport.internet.splithttp.Config.httpDemux:type_name -> xray.transport.internet.splithttp.Multiplexing + 1, // 6: xray.transport.internet.splithttp.Multiplexing.connectionReuseTimes:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 7: xray.transport.internet.splithttp.Multiplexing.connectionLifetimeMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 8: xray.transport.internet.splithttp.Multiplexing.connections:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 9: xray.transport.internet.splithttp.Multiplexing.concurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 39c72dab0090..7fdc9bac7e77 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -15,7 +15,7 @@ message Config { RandRangeConfig scMinPostsIntervalMs = 6; bool noSSEHeader = 7; RandRangeConfig xPaddingBytes = 8; - Multiplexing httpMux = 9; + Multiplexing httpDemux = 9; } message RandRangeConfig { @@ -24,7 +24,7 @@ message RandRangeConfig { } message Multiplexing { - RandRangeConfig maxUses = 4; + RandRangeConfig connectionReuseTimes = 4; RandRangeConfig connectionLifetimeMs = 5; RandRangeConfig connections = 6; RandRangeConfig concurrency = 7; diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 200fd9c30f81..cbd2b76ac082 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -64,8 +64,8 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in if !found { transportConfig := streamSettings.ProtocolSettings.(*Config) var mux Multiplexing - if transportConfig.HttpMux != nil { - mux = *transportConfig.HttpMux + if transportConfig.HttpDemux != nil { + mux = *transportConfig.HttpDemux } muxManager = NewMuxManager(mux, func() interface{} { diff --git a/transport/internet/splithttp/mux.go b/transport/internet/splithttp/mux.go index fa4ed429b6d2..736f9c4b3cef 100644 --- a/transport/internet/splithttp/mux.go +++ b/transport/internet/splithttp/mux.go @@ -38,12 +38,12 @@ func (m *muxManager) GetResource(ctx context.Context) *muxResource { m.removeExpiredConnections(ctx) if m.connections > 0 && len(m.instances) < int(m.connections) { - errors.LogDebug(ctx, "httpMux: creating client, connections=", len(m.instances)) + errors.LogDebug(ctx, "httpDemux: creating client, connections=", len(m.instances)) return m.newResource() } if len(m.instances) == 0 { - errors.LogDebug(ctx, "httpMux: creating client because instances is empty, connections=", len(m.instances)) + errors.LogDebug(ctx, "httpDemux: creating client because instances is empty, connections=", len(m.instances)) return m.newResource() } @@ -60,7 +60,7 @@ func (m *muxManager) GetResource(ctx context.Context) *muxResource { } if len(clients) == 0 { - errors.LogDebug(ctx, "httpMux: creating client because concurrency was hit, total clients=", len(m.instances)) + errors.LogDebug(ctx, "httpDemux: creating client because concurrency was hit, total clients=", len(m.instances)) return m.newResource() } @@ -73,7 +73,7 @@ func (m *muxManager) GetResource(ctx context.Context) *muxResource { func (m *muxManager) newResource() *muxResource { leftUsage := int32(-1) - if x := m.config.GetNormalizedMaxUses().roll(); x > 0 { + if x := m.config.GetNormalizedConnectionReuseTimes().roll(); x > 0 { leftUsage = x - 1 } expirationTime := time.UnixMilli(0) @@ -94,7 +94,7 @@ func (m *muxManager) removeExpiredConnections(ctx context.Context) { for i := 0; i < len(m.instances); i++ { client := m.instances[i] if client.leftUsage == 0 || (client.expirationTime != time.UnixMilli(0) && time.Now().After(client.expirationTime)) { - errors.LogDebug(ctx, "httpMux: removing client, leftUsage = ", client.leftUsage, ", expirationTime = ", client.expirationTime) + errors.LogDebug(ctx, "httpDemux: removing client, leftUsage = ", client.leftUsage, ", expirationTime = ", client.expirationTime) m.instances = append(m.instances[:i], m.instances[i+1:]...) i-- } diff --git a/transport/internet/splithttp/mux_test.go b/transport/internet/splithttp/mux_test.go index e462d7ff6811..88bf28bde03f 100644 --- a/transport/internet/splithttp/mux_test.go +++ b/transport/internet/splithttp/mux_test.go @@ -28,9 +28,9 @@ func TestConnections(t *testing.T) { } } -func TestMaxUses(t *testing.T) { +func TestConnectionReuseTimes(t *testing.T) { config := Multiplexing{ - MaxUses: &RandRangeConfig{From: 2, To: 2}, + ConnectionReuseTimes: &RandRangeConfig{From: 2, To: 2}, } mux := NewMuxManager(config, func() interface{} { From 78088598895c0afcd1c4e95bd3495207c64a1304 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sun, 15 Sep 2024 11:42:26 -0500 Subject: [PATCH 08/11] x moment --- infra/conf/transport_internet.go | 12 +-- transport/internet/splithttp/config.pb.go | 96 +++++++++++------------ transport/internet/splithttp/config.proto | 2 +- transport/internet/splithttp/dialer.go | 4 +- transport/internet/splithttp/mux.go | 8 +- 5 files changed, 61 insertions(+), 61 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 15dc15afde84..6371d75095eb 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -231,7 +231,7 @@ type SplitHTTPConfig struct { ScMinPostsIntervalMs *Int32Range `json:"scMinPostsIntervalMs"` NoSSEHeader bool `json:"noSSEHeader"` XPaddingBytes *Int32Range `json:"xPaddingBytes"` - HttpDemux SplitHTTPMux `json:"httpDemux"` + Xmux SplitHTTPMux `json:"xmux"` } type SplitHTTPMux struct { @@ -265,10 +265,10 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { // Multiplexing config muxProtobuf := splithttp.Multiplexing{ - ConnectionReuseTimes: splithttpNewRandRangeConfig(c.HttpDemux.ConnectionReuseTimes), - ConnectionLifetimeMs: splithttpNewRandRangeConfig(c.HttpDemux.ConnectionLifetimeMs), - Connections: splithttpNewRandRangeConfig(c.HttpDemux.Connections), - Concurrency: splithttpNewRandRangeConfig(c.HttpDemux.Concurrency), + ConnectionReuseTimes: splithttpNewRandRangeConfig(c.Xmux.ConnectionReuseTimes), + ConnectionLifetimeMs: splithttpNewRandRangeConfig(c.Xmux.ConnectionLifetimeMs), + Connections: splithttpNewRandRangeConfig(c.Xmux.Connections), + Concurrency: splithttpNewRandRangeConfig(c.Xmux.Concurrency), } config := &splithttp.Config{ @@ -280,7 +280,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { ScMinPostsIntervalMs: splithttpNewRandRangeConfig(c.ScMinPostsIntervalMs), NoSSEHeader: c.NoSSEHeader, XPaddingBytes: splithttpNewRandRangeConfig(c.XPaddingBytes), - HttpDemux: &muxProtobuf, + Xmux: &muxProtobuf, } return config, nil } diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 3e8fa9d8c426..1e7c058e0ecd 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -33,7 +33,7 @@ type Config struct { ScMinPostsIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` NoSSEHeader bool `protobuf:"varint,7,opt,name=noSSEHeader,proto3" json:"noSSEHeader,omitempty"` XPaddingBytes *RandRangeConfig `protobuf:"bytes,8,opt,name=xPaddingBytes,proto3" json:"xPaddingBytes,omitempty"` - HttpDemux *Multiplexing `protobuf:"bytes,9,opt,name=httpDemux,proto3" json:"httpDemux,omitempty"` + Xmux *Multiplexing `protobuf:"bytes,9,opt,name=xmux,proto3" json:"xmux,omitempty"` } func (x *Config) Reset() { @@ -124,9 +124,9 @@ func (x *Config) GetXPaddingBytes() *RandRangeConfig { return nil } -func (x *Config) GetHttpDemux() *Multiplexing { +func (x *Config) GetXmux() *Multiplexing { if x != nil { - return x.HttpDemux + return x.Xmux } return nil } @@ -264,7 +264,7 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 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, 0x22, 0xb9, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xaf, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, @@ -300,52 +300,52 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 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, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, - 0x12, 0x4d, 0x0a, 0x09, 0x68, 0x74, 0x74, 0x70, 0x44, 0x65, 0x6d, 0x75, 0x78, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x2f, 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, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, - 0x78, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x68, 0x74, 0x74, 0x70, 0x44, 0x65, 0x6d, 0x75, 0x78, 0x1a, - 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, - 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, - 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, - 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, - 0x6f, 0x22, 0x8a, 0x03, 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, - 0x6e, 0x67, 0x12, 0x66, 0x0a, 0x14, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x04, 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, 0x14, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x66, 0x0a, 0x14, 0x63, 0x6f, - 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, - 0x4d, 0x73, 0x18, 0x05, 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, 0x14, 0x63, 0x6f, - 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, - 0x4d, 0x73, 0x12, 0x54, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x18, 0x06, 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, 0x0b, 0x63, 0x6f, 0x6e, - 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x54, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x63, - 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, + 0x12, 0x43, 0x0a, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, + 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, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x52, + 0x04, 0x78, 0x6d, 0x75, 0x78, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0x8a, 0x03, 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, + 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x66, 0x0a, 0x14, 0x63, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x18, 0x04, 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, 0x14, 0x63, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x12, 0x66, 0x0a, 0x14, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, + 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x05, 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, 0x14, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, + 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x12, 0x54, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 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, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x42, 0x85, - 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 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, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, - 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, - 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, - 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x54, + 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x07, 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, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x63, 0x79, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 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, 0x50, 0x01, + 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, + 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, + 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, + 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -373,7 +373,7 @@ var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ 1, // 2: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig 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.httpDemux:type_name -> xray.transport.internet.splithttp.Multiplexing + 2, // 5: xray.transport.internet.splithttp.Config.xmux:type_name -> xray.transport.internet.splithttp.Multiplexing 1, // 6: xray.transport.internet.splithttp.Multiplexing.connectionReuseTimes:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 7: xray.transport.internet.splithttp.Multiplexing.connectionLifetimeMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 8: xray.transport.internet.splithttp.Multiplexing.connections:type_name -> xray.transport.internet.splithttp.RandRangeConfig diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 7fdc9bac7e77..25476735cffb 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -15,7 +15,7 @@ message Config { RandRangeConfig scMinPostsIntervalMs = 6; bool noSSEHeader = 7; RandRangeConfig xPaddingBytes = 8; - Multiplexing httpDemux = 9; + Multiplexing xmux = 9; } message RandRangeConfig { diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index cbd2b76ac082..60ce330eee7d 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -64,8 +64,8 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in if !found { transportConfig := streamSettings.ProtocolSettings.(*Config) var mux Multiplexing - if transportConfig.HttpDemux != nil { - mux = *transportConfig.HttpDemux + if transportConfig.Xmux != nil { + mux = *transportConfig.Xmux } muxManager = NewMuxManager(mux, func() interface{} { diff --git a/transport/internet/splithttp/mux.go b/transport/internet/splithttp/mux.go index 736f9c4b3cef..bda64621f3ac 100644 --- a/transport/internet/splithttp/mux.go +++ b/transport/internet/splithttp/mux.go @@ -38,12 +38,12 @@ func (m *muxManager) GetResource(ctx context.Context) *muxResource { m.removeExpiredConnections(ctx) if m.connections > 0 && len(m.instances) < int(m.connections) { - errors.LogDebug(ctx, "httpDemux: creating client, connections=", len(m.instances)) + errors.LogDebug(ctx, "xmux: creating client, connections=", len(m.instances)) return m.newResource() } if len(m.instances) == 0 { - errors.LogDebug(ctx, "httpDemux: creating client because instances is empty, connections=", len(m.instances)) + errors.LogDebug(ctx, "xmux: creating client because instances is empty, connections=", len(m.instances)) return m.newResource() } @@ -60,7 +60,7 @@ func (m *muxManager) GetResource(ctx context.Context) *muxResource { } if len(clients) == 0 { - errors.LogDebug(ctx, "httpDemux: creating client because concurrency was hit, total clients=", len(m.instances)) + errors.LogDebug(ctx, "xmux: creating client because concurrency was hit, total clients=", len(m.instances)) return m.newResource() } @@ -94,7 +94,7 @@ func (m *muxManager) removeExpiredConnections(ctx context.Context) { for i := 0; i < len(m.instances); i++ { client := m.instances[i] if client.leftUsage == 0 || (client.expirationTime != time.UnixMilli(0) && time.Now().After(client.expirationTime)) { - errors.LogDebug(ctx, "httpDemux: removing client, leftUsage = ", client.leftUsage, ", expirationTime = ", client.expirationTime) + errors.LogDebug(ctx, "xmux: removing client, leftUsage = ", client.leftUsage, ", expirationTime = ", client.expirationTime) m.instances = append(m.instances[:i], m.instances[i+1:]...) i-- } From 01aef1bd2fe43d751b4acfaebea977934b844c87 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sun, 15 Sep 2024 11:44:20 -0500 Subject: [PATCH 09/11] more x --- infra/conf/transport_internet.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 6371d75095eb..6ad17b812f3b 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -231,10 +231,10 @@ type SplitHTTPConfig struct { ScMinPostsIntervalMs *Int32Range `json:"scMinPostsIntervalMs"` NoSSEHeader bool `json:"noSSEHeader"` XPaddingBytes *Int32Range `json:"xPaddingBytes"` - Xmux SplitHTTPMux `json:"xmux"` + Xmux Xmux `json:"xmux"` } -type SplitHTTPMux struct { +type Xmux struct { ConnectionReuseTimes *Int32Range `json:"connectionReuseTimes"` ConnectionLifetimeMs *Int32Range `json:"connectionLifetimeMs"` Connections *Int32Range `json:"connections"` From b9ffc93919415949a4783dcb99751e2052fb804c Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Mon, 16 Sep 2024 06:24:41 -0500 Subject: [PATCH 10/11] another rename, prohibit connections and concurrency --- infra/conf/transport_internet.go | 20 +++-- transport/internet/splithttp/config.go | 24 +++--- transport/internet/splithttp/config.pb.go | 97 +++++++++++------------ transport/internet/splithttp/config.proto | 8 +- transport/internet/splithttp/mux.go | 8 +- transport/internet/splithttp/mux_test.go | 12 +-- 6 files changed, 86 insertions(+), 83 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 6ad17b812f3b..51a6f33548c7 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -235,10 +235,10 @@ type SplitHTTPConfig struct { } type Xmux struct { - ConnectionReuseTimes *Int32Range `json:"connectionReuseTimes"` - ConnectionLifetimeMs *Int32Range `json:"connectionLifetimeMs"` - Connections *Int32Range `json:"connections"` - Concurrency *Int32Range `json:"concurrency"` + cMaxReuseTimes *Int32Range `json:"cMaxReuseTimes"` + cMaxLifetimeMs *Int32Range `json:"cMaxLifetimeMs"` + maxConnections *Int32Range `json:"connections"` + maxConcurrency *Int32Range `json:"concurrency"` } func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig { @@ -263,12 +263,16 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { 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{ - ConnectionReuseTimes: splithttpNewRandRangeConfig(c.Xmux.ConnectionReuseTimes), - ConnectionLifetimeMs: splithttpNewRandRangeConfig(c.Xmux.ConnectionLifetimeMs), - Connections: splithttpNewRandRangeConfig(c.Xmux.Connections), - Concurrency: splithttpNewRandRangeConfig(c.Xmux.Concurrency), + CMaxReuseTimes: splithttpNewRandRangeConfig(c.Xmux.cMaxReuseTimes), + CMaxLifetimeMs: splithttpNewRandRangeConfig(c.Xmux.cMaxLifetimeMs), + MaxConnections: splithttpNewRandRangeConfig(c.Xmux.maxConnections), + MaxConcurrency: splithttpNewRandRangeConfig(c.Xmux.maxConcurrency), } config := &splithttp.Config{ diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index f931d6bf4af5..5309b1804747 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -105,47 +105,47 @@ func (c *Config) GetNormalizedXPaddingBytes() RandRangeConfig { return *c.XPaddingBytes } -func (m *Multiplexing) GetNormalizedConnectionReuseTimes() RandRangeConfig { - if m.ConnectionReuseTimes == nil { +func (m *Multiplexing) GetNormalizedCMaxReuseTimes() RandRangeConfig { + if m.CMaxReuseTimes == nil { return RandRangeConfig{ From: 0, To: 0, } } - return *m.ConnectionReuseTimes + return *m.CMaxReuseTimes } -func (m *Multiplexing) GetNormalizedConnectionLifetimeMs() RandRangeConfig { - if m.ConnectionLifetimeMs == nil || m.ConnectionLifetimeMs.To == 0 { +func (m *Multiplexing) GetNormalizedCMaxLifetimeMs() RandRangeConfig { + if m.CMaxLifetimeMs == nil || m.CMaxLifetimeMs.To == 0 { return RandRangeConfig{ From: 0, To: 0, } } - return *m.ConnectionLifetimeMs + return *m.CMaxLifetimeMs } -func (m *Multiplexing) GetNormalizedConnections() RandRangeConfig { - if m.Connections == nil { +func (m *Multiplexing) GetNormalizedMaxConnections() RandRangeConfig { + if m.MaxConnections == nil { return RandRangeConfig{ From: 0, To: 0, } } - return *m.Connections + return *m.MaxConnections } -func (m *Multiplexing) GetNormalizedConcurrency() RandRangeConfig { - if m.Concurrency == nil { +func (m *Multiplexing) GetNormalizedMaxConcurrency() RandRangeConfig { + if m.MaxConcurrency == nil { return RandRangeConfig{ From: 0, To: 0, } } - return *m.Concurrency + return *m.MaxConcurrency } func init() { diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 1e7c058e0ecd..94577a78ce13 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -191,10 +191,10 @@ type Multiplexing struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ConnectionReuseTimes *RandRangeConfig `protobuf:"bytes,4,opt,name=connectionReuseTimes,proto3" json:"connectionReuseTimes,omitempty"` - ConnectionLifetimeMs *RandRangeConfig `protobuf:"bytes,5,opt,name=connectionLifetimeMs,proto3" json:"connectionLifetimeMs,omitempty"` - Connections *RandRangeConfig `protobuf:"bytes,6,opt,name=connections,proto3" json:"connections,omitempty"` - Concurrency *RandRangeConfig `protobuf:"bytes,7,opt,name=concurrency,proto3" json:"concurrency,omitempty"` + CMaxReuseTimes *RandRangeConfig `protobuf:"bytes,4,opt,name=cMaxReuseTimes,proto3" json:"cMaxReuseTimes,omitempty"` + CMaxLifetimeMs *RandRangeConfig `protobuf:"bytes,5,opt,name=cMaxLifetimeMs,proto3" json:"cMaxLifetimeMs,omitempty"` + MaxConnections *RandRangeConfig `protobuf:"bytes,6,opt,name=maxConnections,proto3" json:"maxConnections,omitempty"` + MaxConcurrency *RandRangeConfig `protobuf:"bytes,7,opt,name=maxConcurrency,proto3" json:"maxConcurrency,omitempty"` } func (x *Multiplexing) Reset() { @@ -229,30 +229,30 @@ func (*Multiplexing) Descriptor() ([]byte, []int) { return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{2} } -func (x *Multiplexing) GetConnectionReuseTimes() *RandRangeConfig { +func (x *Multiplexing) GetCMaxReuseTimes() *RandRangeConfig { if x != nil { - return x.ConnectionReuseTimes + return x.CMaxReuseTimes } return nil } -func (x *Multiplexing) GetConnectionLifetimeMs() *RandRangeConfig { +func (x *Multiplexing) GetCMaxLifetimeMs() *RandRangeConfig { if x != nil { - return x.ConnectionLifetimeMs + return x.CMaxLifetimeMs } return nil } -func (x *Multiplexing) GetConnections() *RandRangeConfig { +func (x *Multiplexing) GetMaxConnections() *RandRangeConfig { if x != nil { - return x.Connections + return x.MaxConnections } return nil } -func (x *Multiplexing) GetConcurrency() *RandRangeConfig { +func (x *Multiplexing) GetMaxConcurrency() *RandRangeConfig { if x != nil { - return x.Concurrency + return x.MaxConcurrency } return nil } @@ -311,41 +311,40 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0x8a, 0x03, 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, - 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x66, 0x0a, 0x14, 0x63, 0x6f, 0x6e, 0x6e, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, - 0x18, 0x04, 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, 0x14, 0x63, 0x6f, 0x6e, 0x6e, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, - 0x12, 0x66, 0x0a, 0x14, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, - 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, + 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, 0x63, 0x4d, 0x61, 0x78, + 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x04, 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, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, + 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x05, 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, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, + 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x18, 0x06, 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, 0x07, + 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, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 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, 0x14, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, - 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x12, 0x54, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 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, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x54, - 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x07, 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, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, - 0x65, 0x6e, 0x63, 0x79, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 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, 0x50, 0x01, - 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, - 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, - 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, - 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, + 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -374,10 +373,10 @@ 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.connectionReuseTimes:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 7: xray.transport.internet.splithttp.Multiplexing.connectionLifetimeMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 8: xray.transport.internet.splithttp.Multiplexing.connections:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 9: xray.transport.internet.splithttp.Multiplexing.concurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 6: xray.transport.internet.splithttp.Multiplexing.cMaxReuseTimes:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 7: xray.transport.internet.splithttp.Multiplexing.cMaxLifetimeMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 8: xray.transport.internet.splithttp.Multiplexing.maxConnections:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 9: xray.transport.internet.splithttp.Multiplexing.maxConcurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig 10, // [10:10] is the sub-list for method output_type 10, // [10:10] is the sub-list for method input_type 10, // [10:10] is the sub-list for extension type_name diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 25476735cffb..060da6978082 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -24,8 +24,8 @@ message RandRangeConfig { } message Multiplexing { - RandRangeConfig connectionReuseTimes = 4; - RandRangeConfig connectionLifetimeMs = 5; - RandRangeConfig connections = 6; - RandRangeConfig concurrency = 7; + RandRangeConfig cMaxReuseTimes = 4; + RandRangeConfig cMaxLifetimeMs = 5; + RandRangeConfig maxConnections = 6; + RandRangeConfig maxConcurrency = 7; } diff --git a/transport/internet/splithttp/mux.go b/transport/internet/splithttp/mux.go index bda64621f3ac..83ab25b0a4f6 100644 --- a/transport/internet/splithttp/mux.go +++ b/transport/internet/splithttp/mux.go @@ -27,8 +27,8 @@ type muxManager struct { func NewMuxManager(config Multiplexing, newResource func() interface{}) *muxManager { return &muxManager{ config: config, - concurrency: config.GetNormalizedConcurrency().roll(), - connections: config.GetNormalizedConnections().roll(), + concurrency: config.GetNormalizedMaxConcurrency().roll(), + connections: config.GetNormalizedMaxConnections().roll(), newResourceFn: newResource, instances: make([]*muxResource, 0), } @@ -73,11 +73,11 @@ func (m *muxManager) GetResource(ctx context.Context) *muxResource { func (m *muxManager) newResource() *muxResource { leftUsage := int32(-1) - if x := m.config.GetNormalizedConnectionReuseTimes().roll(); x > 0 { + if x := m.config.GetNormalizedCMaxReuseTimes().roll(); x > 0 { leftUsage = x - 1 } expirationTime := time.UnixMilli(0) - if x := m.config.GetNormalizedConnectionLifetimeMs().roll(); x > 0 { + if x := m.config.GetNormalizedCMaxLifetimeMs().roll(); x > 0 { expirationTime = time.Now().Add(time.Duration(x) * time.Millisecond) } diff --git a/transport/internet/splithttp/mux_test.go b/transport/internet/splithttp/mux_test.go index 88bf28bde03f..e59eff0e05c6 100644 --- a/transport/internet/splithttp/mux_test.go +++ b/transport/internet/splithttp/mux_test.go @@ -9,9 +9,9 @@ import ( type fakeRoundTripper struct{} -func TestConnections(t *testing.T) { +func TestMaxConnections(t *testing.T) { config := Multiplexing{ - Connections: &RandRangeConfig{From: 4, To: 4}, + MaxConnections: &RandRangeConfig{From: 4, To: 4}, } mux := NewMuxManager(config, func() interface{} { @@ -28,9 +28,9 @@ func TestConnections(t *testing.T) { } } -func TestConnectionReuseTimes(t *testing.T) { +func TestCMaxReuseTimes(t *testing.T) { config := Multiplexing{ - ConnectionReuseTimes: &RandRangeConfig{From: 2, To: 2}, + CMaxReuseTimes: &RandRangeConfig{From: 2, To: 2}, } mux := NewMuxManager(config, func() interface{} { @@ -47,9 +47,9 @@ func TestConnectionReuseTimes(t *testing.T) { } } -func TestConcurrency(t *testing.T) { +func TestMaxConcurrency(t *testing.T) { config := Multiplexing{ - Concurrency: &RandRangeConfig{From: 2, To: 2}, + MaxConcurrency: &RandRangeConfig{From: 2, To: 2}, } mux := NewMuxManager(config, func() interface{} { From bc7cf58fbf8e4c3a15009d9f5a0ca56bfdd1a478 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Mon, 16 Sep 2024 06:49:35 -0500 Subject: [PATCH 11/11] fix json parsing, fix order --- infra/conf/transport_internet.go | 8 ++-- transport/internet/splithttp/config.pb.go | 58 +++++++++++------------ transport/internet/splithttp/config.proto | 8 ++-- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 51a6f33548c7..7bb4fd6db801 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"` - maxConnections *Int32Range `json:"connections"` - maxConcurrency *Int32Range `json:"concurrency"` } func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig { @@ -269,10 +269,10 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { // Multiplexing config muxProtobuf := splithttp.Multiplexing{ - CMaxReuseTimes: splithttpNewRandRangeConfig(c.Xmux.cMaxReuseTimes), - CMaxLifetimeMs: splithttpNewRandRangeConfig(c.Xmux.cMaxLifetimeMs), MaxConnections: splithttpNewRandRangeConfig(c.Xmux.maxConnections), MaxConcurrency: splithttpNewRandRangeConfig(c.Xmux.maxConcurrency), + 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 94577a78ce13..51fc2091dc7e 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -191,10 +191,10 @@ type Multiplexing struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - CMaxReuseTimes *RandRangeConfig `protobuf:"bytes,4,opt,name=cMaxReuseTimes,proto3" json:"cMaxReuseTimes,omitempty"` - CMaxLifetimeMs *RandRangeConfig `protobuf:"bytes,5,opt,name=cMaxLifetimeMs,proto3" json:"cMaxLifetimeMs,omitempty"` - MaxConnections *RandRangeConfig `protobuf:"bytes,6,opt,name=maxConnections,proto3" json:"maxConnections,omitempty"` - MaxConcurrency *RandRangeConfig `protobuf:"bytes,7,opt,name=maxConcurrency,proto3" json:"maxConcurrency,omitempty"` + MaxConnections *RandRangeConfig `protobuf:"bytes,1,opt,name=maxConnections,proto3" json:"maxConnections,omitempty"` + MaxConcurrency *RandRangeConfig `protobuf:"bytes,2,opt,name=maxConcurrency,proto3" json:"maxConcurrency,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"` } func (x *Multiplexing) Reset() { @@ -229,30 +229,30 @@ func (*Multiplexing) Descriptor() ([]byte, []int) { return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{2} } -func (x *Multiplexing) GetCMaxReuseTimes() *RandRangeConfig { +func (x *Multiplexing) GetMaxConnections() *RandRangeConfig { if x != nil { - return x.CMaxReuseTimes + return x.MaxConnections } return nil } -func (x *Multiplexing) GetCMaxLifetimeMs() *RandRangeConfig { +func (x *Multiplexing) GetMaxConcurrency() *RandRangeConfig { if x != nil { - return x.CMaxLifetimeMs + return x.MaxConcurrency } return nil } -func (x *Multiplexing) GetMaxConnections() *RandRangeConfig { +func (x *Multiplexing) GetCMaxReuseTimes() *RandRangeConfig { if x != nil { - return x.MaxConnections + return x.CMaxReuseTimes } return nil } -func (x *Multiplexing) GetMaxConcurrency() *RandRangeConfig { +func (x *Multiplexing) GetCMaxLifetimeMs() *RandRangeConfig { if x != nil { - return x.MaxConcurrency + return x.CMaxLifetimeMs } return nil } @@ -312,30 +312,30 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 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, 0x63, 0x4d, 0x61, 0x78, - 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, + 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, 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, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, - 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, + 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, 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, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, - 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, + 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, 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, 0x07, + 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, + 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x0e, + 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x04, 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, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, + 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, + 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 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, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, @@ -373,10 +373,10 @@ 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.cMaxReuseTimes:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 7: xray.transport.internet.splithttp.Multiplexing.cMaxLifetimeMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 8: xray.transport.internet.splithttp.Multiplexing.maxConnections:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 9: xray.transport.internet.splithttp.Multiplexing.maxConcurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 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, // 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 10, // [10:10] is the sub-list for method input_type 10, // [10:10] is the sub-list for extension type_name diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 060da6978082..019f4d00f2a7 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -24,8 +24,8 @@ message RandRangeConfig { } message Multiplexing { - RandRangeConfig cMaxReuseTimes = 4; - RandRangeConfig cMaxLifetimeMs = 5; - RandRangeConfig maxConnections = 6; - RandRangeConfig maxConcurrency = 7; + RandRangeConfig maxConnections = 1; + RandRangeConfig maxConcurrency = 2; + RandRangeConfig cMaxReuseTimes = 3; + RandRangeConfig cMaxLifetimeMs = 4; }