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)
This commit is contained in:
mmmray 2024-07-29 12:10:29 +02:00 committed by GitHub
parent 33daa0c94b
commit 30af792777
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 85 additions and 99 deletions

View file

@ -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)
}