summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/reverseproxy/selectionpolicies.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2022-07-28 15:40:23 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2022-07-28 15:40:23 -0600
commit35a81d7c5b4ea2bb055ec0e7e56840d45a5fe60c (patch)
tree82853903bc1a3003dc651d6f56e13cf44f06b8d2 /modules/caddyhttp/reverseproxy/selectionpolicies.go
parent2e70d1d3bfaf4b789b66e84ba60ee855ab327be3 (diff)
Ignore linter warnings
Use of non-cryptographic random numbers in the load balancing is intentional.
Diffstat (limited to 'modules/caddyhttp/reverseproxy/selectionpolicies.go')
-rw-r--r--modules/caddyhttp/reverseproxy/selectionpolicies.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/caddyhttp/reverseproxy/selectionpolicies.go b/modules/caddyhttp/reverseproxy/selectionpolicies.go
index 125a07f..5fc7136 100644
--- a/modules/caddyhttp/reverseproxy/selectionpolicies.go
+++ b/modules/caddyhttp/reverseproxy/selectionpolicies.go
@@ -132,7 +132,7 @@ func (r RandomChoiceSelection) Select(pool UpstreamPool, _ *http.Request, _ http
if !upstream.Available() {
continue
}
- j := weakrand.Intn(i + 1)
+ j := weakrand.Intn(i + 1) //nolint:gosec
if j < k {
choices[j] = upstream
}
@@ -181,7 +181,7 @@ func (LeastConnSelection) Select(pool UpstreamPool, _ *http.Request, _ http.Resp
// sample: https://en.wikipedia.org/wiki/Reservoir_sampling
if numReqs == leastReqs {
count++
- if (weakrand.Int() % count) == 0 {
+ if (weakrand.Int() % count) == 0 { //nolint:gosec
bestHost = host
}
}
@@ -475,7 +475,7 @@ func selectRandomHost(pool []*Upstream) *Upstream {
// upstream will always be chosen if there is at
// least one available
count++
- if (weakrand.Int() % count) == 0 {
+ if (weakrand.Int() % count) == 0 { //nolint:gosec
randomHost = upstream
}
}
@@ -511,7 +511,7 @@ func leastRequests(upstreams []*Upstream) *Upstream {
if len(best) == 0 {
return nil
}
- return best[weakrand.Intn(len(best))]
+ return best[weakrand.Intn(len(best))] //nolint:gosec
}
// hostByHashing returns an available host from pool based on a hashable string s.