SplitHTTP: More range options, change defaults, enforce maxUploadSize, fix querystring behavior (#3603)

* maxUploadSize and maxConcurrentUploads can now be ranges on the client
* maxUploadSize is now enforced on the server
* the default of maxUploadSize is 2MB on the server, and 1MB on the client
* the default of maxConcurrentUploads is 200 on the server, and 100 on the client
* ranges on the server are treated as a single number. if server is configured as `"1-2"`, server will enforce `2`
* querystrings in `path` are now handled correctly
This commit is contained in:
mmmray 2024-07-29 06:35:17 +02:00 committed by GitHub
parent 4cb2a128db
commit 59f6685774
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 223 additions and 82 deletions

View file

@ -181,8 +181,8 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
transportConfiguration := streamSettings.ProtocolSettings.(*Config)
tlsConfig := tls.ConfigFromStreamSettings(streamSettings)
maxConcurrentUploads := transportConfiguration.GetNormalizedMaxConcurrentUploads()
maxUploadSize := transportConfiguration.GetNormalizedMaxUploadSize()
maxConcurrentUploads := transportConfiguration.GetNormalizedMaxConcurrentUploads(false)
maxUploadSize := transportConfiguration.GetNormalizedMaxUploadSize(false)
minUploadInterval := transportConfiguration.GetNormalizedMinUploadInterval()
if tlsConfig != nil {
@ -194,18 +194,17 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
if requestURL.Host == "" {
requestURL.Host = dest.NetAddr()
}
requestURL.Path = transportConfiguration.GetNormalizedPath()
sessionIdUuid := uuid.New()
requestURL.Path = transportConfiguration.GetNormalizedPath(sessionIdUuid.String(), true)
baseURL := requestURL.String()
httpClient := getHTTPClient(ctx, dest, streamSettings)
sessionIdUuid := uuid.New()
sessionId := sessionIdUuid.String()
baseURL := requestURL.String() + sessionId
uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize))
uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize.roll()))
go func() {
requestsLimiter := semaphore.New(int(maxConcurrentUploads))
requestsLimiter := semaphore.New(int(maxConcurrentUploads.roll()))
var requestCounter int64
lastWrite := time.Now()