diff options
Diffstat (limited to 'plugin/grpc/grpc.go')
-rw-r--r-- | plugin/grpc/grpc.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/plugin/grpc/grpc.go b/plugin/grpc/grpc.go index 3dda225df..878b6c3f4 100644 --- a/plugin/grpc/grpc.go +++ b/plugin/grpc/grpc.go @@ -7,6 +7,7 @@ import ( "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin/debug" + "github.com/coredns/coredns/plugin/pkg/policy" "github.com/coredns/coredns/request" "github.com/miekg/dns" @@ -17,7 +18,7 @@ import ( // It has a list of proxies each representing one upstream proxy. type GRPC struct { proxies []*Proxy - p Policy + p policy.Policy from string ignored []string @@ -93,7 +94,7 @@ func (g *GRPC) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ( // NewGRPC returns a new GRPC. func newGRPC() *GRPC { g := &GRPC{ - p: new(random), + p: new(policy.Random), } return g } @@ -126,6 +127,11 @@ func (g *GRPC) isAllowedDomain(name string) bool { } // List returns a set of proxies to be used for this client depending on the policy in p. -func (g *GRPC) list() []*Proxy { return g.p.List(g.proxies) } +func (g *GRPC) list() []*Proxy { + if len(g.p.List(g.proxies)) == 1 { + return g.p.List(g.proxies)[0].([]*Proxy) + } + return nil +} const defaultTimeout = 5 * time.Second |