aboutsummaryrefslogtreecommitdiff
path: root/core/dnsserver/server.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2019-03-07 20:23:00 +0000
committerGravatar GitHub <noreply@github.com> 2019-03-07 20:23:00 +0000
commit2b7e84a076e38cfc67a69b2c0c8dec106585d4b9 (patch)
treedcbc54a1ba3e13e3115b20985b2e38880ba1c053 /core/dnsserver/server.go
parent18d305f4b3eaf398215fa704b681c4778376a8a8 (diff)
downloadcoredns-2b7e84a076e38cfc67a69b2c0c8dec106585d4b9.tar.gz
coredns-2b7e84a076e38cfc67a69b2c0c8dec106585d4b9.tar.zst
coredns-2b7e84a076e38cfc67a69b2c0c8dec106585d4b9.zip
Remove internal loop detection (#2647)
* Remove internal loop detection I can't actually think of a situation where we can create an internal loop. Sure externally triggered cycles can happen, but this is where the *loop* plugin comes in that detects those. Fixes #2602 Signed-off-by: Miek Gieben <miek@miek.nl> * Remove test Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'core/dnsserver/server.go')
-rw-r--r--core/dnsserver/server.go31
1 files changed, 2 insertions, 29 deletions
diff --git a/core/dnsserver/server.go b/core/dnsserver/server.go
index 22ab8e1c3..2fc1529d1 100644
--- a/core/dnsserver/server.go
+++ b/core/dnsserver/server.go
@@ -230,12 +230,6 @@ func (s *Server) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
return
}
- ctx, err := incrementDepthAndCheck(ctx)
- if err != nil {
- DefaultErrorFunc(ctx, w, r, dns.RcodeServerFailure)
- return
- }
-
q := r.Question[0].Name
b := make([]byte, len(q))
var off int
@@ -356,35 +350,14 @@ func DefaultErrorFunc(ctx context.Context, w dns.ResponseWriter, r *dns.Msg, rc
w.WriteMsg(answer)
}
-// incrementDepthAndCheck increments the loop counter in the context, and returns an error if
-// the counter exceeds the max number of re-entries
-func incrementDepthAndCheck(ctx context.Context) (context.Context, error) {
- // Loop counter for self directed lookups
- loop := ctx.Value(loopKey{})
- if loop == nil {
- ctx = context.WithValue(ctx, loopKey{}, 0)
- return ctx, nil
- }
-
- iloop := loop.(int) + 1
- if iloop > maxreentries {
- return ctx, fmt.Errorf("too deep")
- }
- ctx = context.WithValue(ctx, loopKey{}, iloop)
- return ctx, nil
-}
-
const (
tcp = 0
udp = 1
maxreentries = 10
)
-type (
- // Key is the context key for the current server
- Key struct{}
- loopKey struct{} // loopKey is the context key for counting self loops
-)
+// Key is the context key for the current server
+type Key struct{}
// EnableChaos is a map with plugin names for which we should open CH class queries as we block these by default.
var EnableChaos = map[string]struct{}{