add wildcard warnings (#5030)

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
Chris O'Haver 2021-12-09 11:24:48 -05:00 committed by GitHub
parent e5ea3341fa
commit 744468ea78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 0 deletions

View file

@ -7,6 +7,8 @@ import (
"os"
"strconv"
"strings"
"sync/atomic"
"time"
"github.com/coredns/caddy"
"github.com/coredns/coredns/core/dnsserver"
@ -61,6 +63,25 @@ func setup(c *caddy.Controller) error {
return nil
})
wildWarner := time.NewTicker(10 * time.Second)
c.OnStartup(func() error {
go func() {
for {
select {
case <-wildWarner.C:
if wc := atomic.SwapUint64(&wildCount, 0); wc > 0 {
log.Warningf("%d deprecated wildcard queries received. Wildcard queries will no longer be supported in the next minor release.", wc)
}
}
}
}()
return nil
})
c.OnShutdown(func() error {
wildWarner.Stop()
return nil
})
return nil
}