accounting: fix --bwlimit when up or down is off - fixes #5019

Before this change the core bandwidth limit was limited to upload or
download value if the other value was off.

This fix only applies a core bandwidth limit when both values are set.
This commit is contained in:
Nick Craig-Wood 2021-02-12 21:15:23 +00:00
parent e779cacc82
commit 2aebeb6061
1 changed files with 2 additions and 1 deletions

View File

@ -68,7 +68,8 @@ func newTokenBucket(bandwidth fs.BwPair) (tbs buckets) {
bandwidthAccounting = bandwidth.Rx
}
}
if bandwidthAccounting > 0 {
// Limit core bandwidth to max of Rx and Tx if both are limited
if bandwidth.Tx > 0 && bandwidth.Rx > 0 {
tbs[TokenBucketSlotAccounting] = rate.NewLimiter(rate.Limit(bandwidthAccounting), maxBurstSize)
}
for _, tb := range tbs {