diff options
author | 2021-12-09 11:24:48 -0500 | |
---|---|---|
committer | 2021-12-09 08:24:48 -0800 | |
commit | 744468ea78e278bb59c1e50673ff5028ebea539c (patch) | |
tree | b786dd76f55311a97a3e613614e8279f291cdafe /plugin/kubernetes/handler.go | |
parent | e5ea3341fac46c31b09119d0f73457123050d7e0 (diff) | |
download | coredns-744468ea78e278bb59c1e50673ff5028ebea539c.tar.gz coredns-744468ea78e278bb59c1e50673ff5028ebea539c.tar.zst coredns-744468ea78e278bb59c1e50673ff5028ebea539c.zip |
add wildcard warnings (#5030)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/kubernetes/handler.go')
-rw-r--r-- | plugin/kubernetes/handler.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/plugin/kubernetes/handler.go b/plugin/kubernetes/handler.go index 336fd08db..b232417a3 100644 --- a/plugin/kubernetes/handler.go +++ b/plugin/kubernetes/handler.go @@ -2,6 +2,8 @@ package kubernetes import ( "context" + "strings" + "sync/atomic" "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/request" @@ -27,6 +29,10 @@ func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M err error ) + if wildQuestion(state.Name()) { + atomic.AddUint64(&wildCount, 1) + } + switch state.QType() { case dns.TypeA: records, err = plugin.A(ctx, &k, zone, state, nil, plugin.Options{}) @@ -85,8 +91,13 @@ func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M m.Answer = append(m.Answer, records...) m.Extra = append(m.Extra, extra...) w.WriteMsg(m) + return dns.RcodeSuccess, nil } +func wildQuestion(name string) bool { + return strings.HasPrefix(name, "*.") || strings.HasPrefix(name, "any.") || strings.Contains(name, ".*.") || strings.Contains(name, ".any.") +} + // Name implements the Handler interface. func (k Kubernetes) Name() string { return "kubernetes" } |