@marcel91200 / caddy Mirror · read-only / commits / 35a81d7c
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 13, 15:30 UTC

Ignore linter warnings

Use of non-cryptographic random numbers in the load balancing is intentional.

Matthew Holt committed Jul 28, 2022 at 15:40 UTC 35a81d7c5b4ea2bb055ec0e7e56840d45a5fe60c
1 file changed +4 -4
modules/caddyhttp/reverseproxy/selectionpolicies.go
+4 -4
@@ -132,7 +132,7 @@ func (r RandomChoiceSelection) Select(pool UpstreamPool, _ *http.Request, _ http
132 if !upstream.Available() {
133 continue
134 }
135 - j := weakrand.Intn(i + 1)
135 + j := weakrand.Intn(i + 1) //nolint:gosec
136 if j < k {
137 choices[j] = upstream
138 }
@@ -181,7 +181,7 @@ func (LeastConnSelection) Select(pool UpstreamPool, _ *http.Request, _ http.Resp
181 // sample: https://en.wikipedia.org/wiki/Reservoir_sampling
182 if numReqs == leastReqs {
183 count++
184 - if (weakrand.Int() % count) == 0 {
184 + if (weakrand.Int() % count) == 0 { //nolint:gosec
185 bestHost = host
186 }
187 }
@@ -475,7 +475,7 @@ func selectRandomHost(pool []*Upstream) *Upstream {
475 // upstream will always be chosen if there is at
476 // least one available
477 count++
478 - if (weakrand.Int() % count) == 0 {
478 + if (weakrand.Int() % count) == 0 { //nolint:gosec
479 randomHost = upstream
480 }
481 }
@@ -511,7 +511,7 @@ func leastRequests(upstreams []*Upstream) *Upstream {
511 if len(best) == 0 {
512 return nil
513 }
514 - return best[weakrand.Intn(len(best))]
514 + return best[weakrand.Intn(len(best))] //nolint:gosec
515 }
516
517 // hostByHashing returns an available host from pool based on a hashable string s.