mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-30 22:34:15 -05:00
Ignore linter warnings
Use of non-cryptographic random numbers in the load balancing is intentional.
This commit is contained in:
parent
2e70d1d3bf
commit
35a81d7c5b
1 changed files with 4 additions and 4 deletions
|
@ -132,7 +132,7 @@ func (r RandomChoiceSelection) Select(pool UpstreamPool, _ *http.Request, _ http
|
||||||
if !upstream.Available() {
|
if !upstream.Available() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
j := weakrand.Intn(i + 1)
|
j := weakrand.Intn(i + 1) //nolint:gosec
|
||||||
if j < k {
|
if j < k {
|
||||||
choices[j] = upstream
|
choices[j] = upstream
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ func (LeastConnSelection) Select(pool UpstreamPool, _ *http.Request, _ http.Resp
|
||||||
// sample: https://en.wikipedia.org/wiki/Reservoir_sampling
|
// sample: https://en.wikipedia.org/wiki/Reservoir_sampling
|
||||||
if numReqs == leastReqs {
|
if numReqs == leastReqs {
|
||||||
count++
|
count++
|
||||||
if (weakrand.Int() % count) == 0 {
|
if (weakrand.Int() % count) == 0 { //nolint:gosec
|
||||||
bestHost = host
|
bestHost = host
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -475,7 +475,7 @@ func selectRandomHost(pool []*Upstream) *Upstream {
|
||||||
// upstream will always be chosen if there is at
|
// upstream will always be chosen if there is at
|
||||||
// least one available
|
// least one available
|
||||||
count++
|
count++
|
||||||
if (weakrand.Int() % count) == 0 {
|
if (weakrand.Int() % count) == 0 { //nolint:gosec
|
||||||
randomHost = upstream
|
randomHost = upstream
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -511,7 +511,7 @@ func leastRequests(upstreams []*Upstream) *Upstream {
|
||||||
if len(best) == 0 {
|
if len(best) == 0 {
|
||||||
return nil
|
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.
|
// hostByHashing returns an available host from pool based on a hashable string s.
|
||||||
|
|
Loading…
Reference in a new issue