Middleware chaining fixes

For prometheus use the plain value, not a pointer and change all usages.
Allow AXFR to be requested over udp as well and some other more log
printed when commencing an AXFR.
This commit is contained in:
Miek Gieben
2016-04-05 15:54:06 +01:00
parent c961acbb6e
commit 8892a1b490
6 changed files with 16 additions and 19 deletions

View File

@@ -2,6 +2,7 @@ package file
import (
"fmt"
"log"
"github.com/miekg/coredns/middleware"
@@ -24,9 +25,6 @@ func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (in
if state.QType() != dns.TypeAXFR {
return 0, fmt.Errorf("xfr called with non transfer type: %d", state.QType())
}
if state.Proto() == "udp" {
return 0, fmt.Errorf("xfr called with udp")
}
records := x.All()
if len(records) == 0 {
@@ -40,6 +38,7 @@ func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (in
j, l := 0, 0
records = append(records, records[0]) // add closing SOA to the end
log.Printf("[INFO] Outgoing transfer of %d records of zone %s to %s started", len(records), x.name, state.IP())
for i, r := range records {
l += dns.Len(r)
if l > transferLength {
@@ -57,4 +56,4 @@ func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (in
return dns.RcodeSuccess, nil
}
const transferLength = 100 // Start a new envelop after message reaches this size. Intentionally small to test multi envelope parsing
const transferLength = 1000 // Start a new envelop after message reaches this size in bytes. Intentionally small to test multi envelope parsing.