fix(grpc): check proxy list length in policies (#7512)

This commit is contained in:
Ville Vesilehto
2025-09-04 02:24:44 +03:00
committed by GitHub
parent abef207695
commit 066e51675c
2 changed files with 133 additions and 0 deletions

View File

@@ -20,6 +20,8 @@ func (r *random) String() string { return "random" }
func (r *random) List(p []*Proxy) []*Proxy {
switch len(p) {
case 0:
return nil
case 1:
return p
case 2:
@@ -46,6 +48,9 @@ type roundRobin struct {
func (r *roundRobin) String() string { return "round_robin" }
func (r *roundRobin) List(p []*Proxy) []*Proxy {
if len(p) == 0 {
return nil
}
poolLen := uint32(len(p))
i := atomic.AddUint32(&r.robin, 1) % poolLen