mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-15 04:47:16 +03:00
SplitHTTP client: Add minUploadInterval (#3592)
This commit is contained in:
@ -183,6 +183,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
|
||||
|
||||
maxConcurrentUploads := transportConfiguration.GetNormalizedMaxConcurrentUploads()
|
||||
maxUploadSize := transportConfiguration.GetNormalizedMaxUploadSize()
|
||||
minUploadInterval := transportConfiguration.GetNormalizedMinUploadInterval()
|
||||
|
||||
if tlsConfig != nil {
|
||||
requestURL.Scheme = "https"
|
||||
@ -207,6 +208,8 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
|
||||
requestsLimiter := semaphore.New(int(maxConcurrentUploads))
|
||||
var requestCounter int64
|
||||
|
||||
lastWrite := time.Now()
|
||||
|
||||
// by offloading the uploads into a buffered pipe, multiple conn.Write
|
||||
// calls get automatically batched together into larger POST requests.
|
||||
// without batching, bandwidth is extremely limited.
|
||||
@ -237,6 +240,14 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
|
||||
}
|
||||
}()
|
||||
|
||||
if minUploadInterval.From > 0 {
|
||||
roll := time.Duration(minUploadInterval.roll()) * time.Millisecond
|
||||
if time.Since(lastWrite) < roll {
|
||||
time.Sleep(roll)
|
||||
}
|
||||
|
||||
lastWrite = time.Now()
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
Reference in New Issue
Block a user