aboutsummaryrefslogtreecommitdiff
path: root/plugin/kubernetes/handler.go
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2021-12-09 11:24:48 -0500
committerGravatar GitHub <noreply@github.com> 2021-12-09 08:24:48 -0800
commit744468ea78e278bb59c1e50673ff5028ebea539c (patch)
treeb786dd76f55311a97a3e613614e8279f291cdafe /plugin/kubernetes/handler.go
parente5ea3341fac46c31b09119d0f73457123050d7e0 (diff)
downloadcoredns-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.go11
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" }