mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 18:53:43 -04:00
fix(grpc): check proxy list length in policies (#7512)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user