aboutsummaryrefslogtreecommitdiff
path: root/core/dnsserver/directives.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-10-24 10:16:03 +0100
committerGravatar GitHub <noreply@github.com> 2017-10-24 10:16:03 +0100
commitfcd0342e42a8be5a1cfe41304f0a8099b1bc0e06 (patch)
tree5fa74c98e7a4c729cd8597f477c14a41ca7503cc /core/dnsserver/directives.go
parent5f813bcc216642021ae50b07a8aead2e73e9d059 (diff)
downloadcoredns-fcd0342e42a8be5a1cfe41304f0a8099b1bc0e06.tar.gz
coredns-fcd0342e42a8be5a1cfe41304f0a8099b1bc0e06.tar.zst
coredns-fcd0342e42a8be5a1cfe41304f0a8099b1bc0e06.zip
CIDR query routing (#1159)
* core: allow all CIDR ranges in zone specifications Allow (e.g.) a v4 reverse on a /17. If a zone is specified in such a way a FilterFunc is set in the config. This filter is checked against incoming queries. For all other queries this adds a 'x != nil' check which will not impact performace too much. Benchmark function is added as well to check for this as wel. Add multiple tests in tests/server_reverse_test.go. Benchmark shows in the non-reverse case this hardly impact the speed: ~~~ classless: pkg: github.com/coredns/coredns/core/dnsserver BenchmarkCoreServeDNS-4 1000000 1431 ns/op 16 B/op 1 allocs/op pkg: github.com/coredns/coredns/core/dnsserver BenchmarkCoreServeDNS-4 1000000 1429 ns/op 16 B/op 1 allocs/op master: pkg: github.com/coredns/coredns/core/dnsserver BenchmarkCoreServeDNS-4 1000000 1412 ns/op 16 B/op 1 allocs/op pkg: github.com/coredns/coredns/core/dnsserver BenchmarkCoreServeDNS-4 1000000 1429 ns/op 16 B/op 1 allocs/op ~~~ * README.md updates
Diffstat (limited to 'core/dnsserver/directives.go')
-rw-r--r--core/dnsserver/directives.go64
1 files changed, 0 insertions, 64 deletions
diff --git a/core/dnsserver/directives.go b/core/dnsserver/directives.go
deleted file mode 100644
index bc37baf11..000000000
--- a/core/dnsserver/directives.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package dnsserver
-
-import (
- "fmt"
- "os"
- "strings"
-)
-
-// RegisterDevDirective splices name into the list of directives
-// immediately before another directive. This function is ONLY
-// for plugin development purposes! NEVER use it for a plugin
-// that you are not currently building. If before is empty,
-// the directive will be appended to the end of the list.
-//
-// It is imperative that directives execute in the proper
-// order, and hard-coding the list of directives guarantees
-// a correct, absolute order every time. This function is
-// convenient when developing a plugin, but it does not
-// guarantee absolute ordering. Multiple plugins registering
-// directives with this function will lead to non-
-// deterministic builds and buggy software.
-//
-// Directive names must be lower-cased and unique. Any errors
-// here are fatal, and even successful calls print a message
-// to stdout as a reminder to use it only in development.
-func RegisterDevDirective(name, before string) {
- if name == "" {
- fmt.Println("[FATAL] Cannot register empty directive name")
- os.Exit(1)
- }
- if strings.ToLower(name) != name {
- fmt.Printf("[FATAL] %s: directive name must be lowercase\n", name)
- os.Exit(1)
- }
- for _, dir := range directives {
- if dir == name {
- fmt.Printf("[FATAL] %s: directive name already exists\n", name)
- os.Exit(1)
- }
- }
- if before == "" {
- directives = append(directives, name)
- } else {
- var found bool
- for i, dir := range directives {
- if dir == before {
- directives = append(directives[:i], append([]string{name}, directives[i:]...)...)
- found = true
- break
- }
- }
- if !found {
- fmt.Printf("[FATAL] %s: directive not found\n", before)
- os.Exit(1)
- }
- }
- msg := fmt.Sprintf("Registered directive '%s' ", name)
- if before == "" {
- msg += "at end of list"
- } else {
- msg += fmt.Sprintf("before '%s'", before)
- }
- fmt.Printf("[INFO] %s\n", msg)
-}