From 30af792777fb3992026e90a066cde73311d9b90b Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Mon, 29 Jul 2024 12:10:29 +0200 Subject: [PATCH] SplitHTTP: Rename three options & Reduce server defaults (#3611) * maxUploadSize -> scMaxEachPostBytes, default is 1MB on both sides (was 2MB on the server) * minUploadIntervalMs -> scMinPostsIntervalMs, default is 30ms on the client (no server support for now) * maxConcurrentUploads -> scMaxConcurrentPosts, default is 100 on both sides (was 200 on the server) --- infra/conf/transport_internet.go | 24 +++---- transport/internet/splithttp/config.go | 44 ++++-------- transport/internet/splithttp/config.pb.go | 88 +++++++++++------------ transport/internet/splithttp/config.proto | 6 +- transport/internet/splithttp/dialer.go | 14 ++-- transport/internet/splithttp/hub.go | 8 +-- 6 files changed, 85 insertions(+), 99 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 40f648b3..f50a1edb 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -229,9 +229,9 @@ type SplitHTTPConfig struct { Host string `json:"host"` Path string `json:"path"` Headers map[string]string `json:"headers"` - MaxConcurrentUploads Int32Range `json:"maxConcurrentUploads"` - MaxUploadSize Int32Range `json:"maxUploadSize"` - MinUploadIntervalMs Int32Range `json:"minUploadIntervalMs"` + ScMaxConcurrentPosts Int32Range `json:"scMaxConcurrentPosts"` + ScMaxEachPostBytes Int32Range `json:"scMaxEachPostBytes"` + ScMinPostsIntervalMs Int32Range `json:"scMinPostsIntervalMs"` NoSSEHeader bool `json:"noSSEHeader"` } @@ -249,17 +249,17 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { Path: c.Path, Host: c.Host, Header: c.Headers, - MaxConcurrentUploads: &splithttp.RandRangeConfig{ - From: c.MaxConcurrentUploads.From, - To: c.MaxConcurrentUploads.To, + ScMaxConcurrentPosts: &splithttp.RandRangeConfig{ + From: c.ScMaxConcurrentPosts.From, + To: c.ScMaxConcurrentPosts.To, }, - MaxUploadSize: &splithttp.RandRangeConfig{ - From: c.MaxUploadSize.From, - To: c.MaxUploadSize.To, + ScMaxEachPostBytes: &splithttp.RandRangeConfig{ + From: c.ScMaxEachPostBytes.From, + To: c.ScMaxEachPostBytes.To, }, - MinUploadIntervalMs: &splithttp.RandRangeConfig{ - From: c.MinUploadIntervalMs.From, - To: c.MinUploadIntervalMs.To, + ScMinPostsIntervalMs: &splithttp.RandRangeConfig{ + From: c.ScMinPostsIntervalMs.From, + To: c.ScMinPostsIntervalMs.To, }, NoSSEHeader: c.NoSSEHeader, } diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 7f2dc3f5..a2595038 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -36,51 +36,37 @@ func (c *Config) GetRequestHeader() http.Header { return header } -func (c *Config) GetNormalizedMaxConcurrentUploads(isServer bool) RandRangeConfig { - if c.MaxConcurrentUploads == nil || c.MaxConcurrentUploads.To == 0 { - if isServer { - return RandRangeConfig{ - From: 200, - To: 200, - } - } else { - return RandRangeConfig{ - From: 100, - To: 100, - } +func (c *Config) GetNormalizedScMaxConcurrentPosts() RandRangeConfig { + if c.ScMaxConcurrentPosts == nil || c.ScMaxConcurrentPosts.To == 0 { + return RandRangeConfig{ + From: 100, + To: 100, } } - return *c.MaxConcurrentUploads + return *c.ScMaxConcurrentPosts } -func (c *Config) GetNormalizedMaxUploadSize(isServer bool) RandRangeConfig { - if c.MaxUploadSize == nil || c.MaxUploadSize.To == 0 { - if isServer { - return RandRangeConfig{ - From: 2000000, - To: 2000000, - } - } else { - return RandRangeConfig{ - From: 1000000, - To: 1000000, - } +func (c *Config) GetNormalizedScMaxEachPostBytes() RandRangeConfig { + if c.ScMaxEachPostBytes == nil || c.ScMaxEachPostBytes.To == 0 { + return RandRangeConfig{ + From: 1000000, + To: 1000000, } } - return *c.MaxUploadSize + return *c.ScMaxEachPostBytes } -func (c *Config) GetNormalizedMinUploadInterval() RandRangeConfig { - if c.MinUploadIntervalMs == nil || c.MinUploadIntervalMs.To == 0 { +func (c *Config) GetNormalizedScMinPostsIntervalMs() RandRangeConfig { + if c.ScMinPostsIntervalMs == nil || c.ScMinPostsIntervalMs.To == 0 { return RandRangeConfig{ From: 30, To: 30, } } - return *c.MinUploadIntervalMs + return *c.ScMinPostsIntervalMs } func init() { diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 8e69867e..c543df00 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -28,9 +28,9 @@ type Config struct { Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` Header map[string]string `protobuf:"bytes,3,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - MaxConcurrentUploads *RandRangeConfig `protobuf:"bytes,4,opt,name=maxConcurrentUploads,proto3" json:"maxConcurrentUploads,omitempty"` - MaxUploadSize *RandRangeConfig `protobuf:"bytes,5,opt,name=maxUploadSize,proto3" json:"maxUploadSize,omitempty"` - MinUploadIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=minUploadIntervalMs,proto3" json:"minUploadIntervalMs,omitempty"` + ScMaxConcurrentPosts *RandRangeConfig `protobuf:"bytes,4,opt,name=scMaxConcurrentPosts,proto3" json:"scMaxConcurrentPosts,omitempty"` + ScMaxEachPostBytes *RandRangeConfig `protobuf:"bytes,5,opt,name=scMaxEachPostBytes,proto3" json:"scMaxEachPostBytes,omitempty"` + ScMinPostsIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` NoSSEHeader bool `protobuf:"varint,7,opt,name=noSSEHeader,proto3" json:"noSSEHeader,omitempty"` } @@ -87,23 +87,23 @@ func (x *Config) GetHeader() map[string]string { return nil } -func (x *Config) GetMaxConcurrentUploads() *RandRangeConfig { +func (x *Config) GetScMaxConcurrentPosts() *RandRangeConfig { if x != nil { - return x.MaxConcurrentUploads + return x.ScMaxConcurrentPosts } return nil } -func (x *Config) GetMaxUploadSize() *RandRangeConfig { +func (x *Config) GetScMaxEachPostBytes() *RandRangeConfig { if x != nil { - return x.MaxUploadSize + return x.ScMaxEachPostBytes } return nil } -func (x *Config) GetMinUploadIntervalMs() *RandRangeConfig { +func (x *Config) GetScMinPostsIntervalMs() *RandRangeConfig { if x != nil { - return x.MinUploadIntervalMs + return x.ScMinPostsIntervalMs } return nil } @@ -177,7 +177,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, 0x84, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0x86, 0x04, 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, @@ -192,37 +192,37 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 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, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x12, 0x58, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x55, - 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, 0x7a, 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, 0x0d, 0x6d, 0x61, 0x78, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, - 0x7a, 0x65, 0x12, 0x64, 0x0a, 0x13, 0x6d, 0x69, 0x6e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x49, - 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 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, 0x13, 0x6d, 0x69, 0x6e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 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, 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, + 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x55, + 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x79, 0x74, 0x65, 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, 0x6d, 0x61, 0x78, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, + 0x79, 0x74, 0x65, 0x73, 0x12, 0x64, 0x0a, 0x13, 0x6d, 0x69, 0x6e, 0x55, 0x70, 0x6c, 0x6f, 0x61, + 0x64, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 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, 0x13, 0x6d, 0x69, 0x6e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, + 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, 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, } var ( @@ -245,9 +245,9 @@ var file_transport_internet_splithttp_config_proto_goTypes = []interface{}{ } 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.maxConcurrentUploads:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 2: xray.transport.internet.splithttp.Config.maxUploadSize:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 3: xray.transport.internet.splithttp.Config.minUploadIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 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 4, // [4:4] is the sub-list for method output_type 4, // [4:4] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 807732c3..b8af30c4 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -10,9 +10,9 @@ message Config { string host = 1; string path = 2; map header = 3; - RandRangeConfig maxConcurrentUploads = 4; - RandRangeConfig maxUploadSize = 5; - RandRangeConfig minUploadIntervalMs = 6; + RandRangeConfig scMaxConcurrentPosts = 4; + RandRangeConfig scMaxEachPostBytes = 5; + RandRangeConfig scMinPostsIntervalMs = 6; bool noSSEHeader = 7; } diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 0448b2f7..07e5d5d1 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -181,9 +181,9 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me transportConfiguration := streamSettings.ProtocolSettings.(*Config) tlsConfig := tls.ConfigFromStreamSettings(streamSettings) - maxConcurrentUploads := transportConfiguration.GetNormalizedMaxConcurrentUploads(false) - maxUploadSize := transportConfiguration.GetNormalizedMaxUploadSize(false) - minUploadInterval := transportConfiguration.GetNormalizedMinUploadInterval() + scMaxConcurrentPosts := transportConfiguration.GetNormalizedScMaxConcurrentPosts() + scMaxEachPostBytes := transportConfiguration.GetNormalizedScMaxEachPostBytes() + scMinPostsIntervalMs := transportConfiguration.GetNormalizedScMinPostsIntervalMs() if tlsConfig != nil { requestURL.Scheme = "https" @@ -201,10 +201,10 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me httpClient := getHTTPClient(ctx, dest, streamSettings) - uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize.roll())) + uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(scMaxEachPostBytes.roll())) go func() { - requestsLimiter := semaphore.New(int(maxConcurrentUploads.roll())) + requestsLimiter := semaphore.New(int(scMaxConcurrentPosts.roll())) var requestCounter int64 lastWrite := time.Now() @@ -239,8 +239,8 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } }() - if minUploadInterval.From > 0 { - roll := time.Duration(minUploadInterval.roll()) * time.Millisecond + if scMinPostsIntervalMs.From > 0 { + roll := time.Duration(scMinPostsIntervalMs.roll()) * time.Millisecond if time.Since(lastWrite) < roll { time.Sleep(roll) } diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index ce54ed07..30bc8b1e 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -76,7 +76,7 @@ func (h *requestHandler) upsertSession(sessionId string) *httpSession { } s := &httpSession{ - uploadQueue: NewUploadQueue(int(h.ln.config.GetNormalizedMaxConcurrentUploads(true).To)), + uploadQueue: NewUploadQueue(int(h.ln.config.GetNormalizedScMaxConcurrentPosts().To)), isFullyConnected: done.New(), } @@ -123,7 +123,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } currentSession := h.upsertSession(sessionId) - maxUploadSize := int(h.ln.config.GetNormalizedMaxUploadSize(true).To) + scMaxEachPostBytes := int(h.ln.config.GetNormalizedScMaxEachPostBytes().To) if request.Method == "POST" { seq := "" @@ -139,8 +139,8 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req payload, err := io.ReadAll(request.Body) - if len(payload) > maxUploadSize { - errors.LogInfo(context.Background(), "Too large upload. maxUploadSize is set to", maxUploadSize, "but request had size", len(payload), ". Adjust maxUploadSize on the server to be at least as large as client.") + if len(payload) > scMaxEachPostBytes { + errors.LogInfo(context.Background(), "Too large upload. scMaxEachPostBytes is set to ", scMaxEachPostBytes, "but request had size ", len(payload), ". Adjust scMaxEachPostBytes on the server to be at least as large as client.") writer.WriteHeader(http.StatusRequestEntityTooLarge) return }