mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-30 17:53:21 -04:00 
			
		
		
		
	add wildcard warnings (#5030)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
		| @@ -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" } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user