aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'plugin')
-rw-r--r--plugin/erratic/erratic.go6
-rw-r--r--plugin/erratic/erratic_test.go16
-rw-r--r--plugin/erratic/setup.go2
3 files changed, 24 insertions, 0 deletions
diff --git a/plugin/erratic/erratic.go b/plugin/erratic/erratic.go
index 3460f3bca..f60e605d1 100644
--- a/plugin/erratic/erratic.go
+++ b/plugin/erratic/erratic.go
@@ -19,6 +19,7 @@ type Erratic struct {
duration time.Duration
truncate uint64
+ large bool // undocumented feature; return large responses for A request (>512B, to test compression).
q uint64 // counter of queries
}
@@ -57,6 +58,11 @@ func (e *Erratic) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
rr := *(rrA.(*dns.A))
rr.Header().Name = state.QName()
m.Answer = append(m.Answer, &rr)
+ if e.large {
+ for i := 0; i < 29; i++ {
+ m.Answer = append(m.Answer, &rr)
+ }
+ }
case dns.TypeAAAA:
rr := *(rrAAAA.(*dns.AAAA))
rr.Header().Name = state.QName()
diff --git a/plugin/erratic/erratic_test.go b/plugin/erratic/erratic_test.go
index 406fd8774..ec2ec5c0a 100644
--- a/plugin/erratic/erratic_test.go
+++ b/plugin/erratic/erratic_test.go
@@ -98,3 +98,19 @@ func TestAxfr(t *testing.T) {
t.Errorf("Expected for record to be %d, got %d", dns.TypeSOA, x)
}
}
+
+func TestErratic(t *testing.T) {
+ e := &Erratic{drop: 0, delay: 0}
+
+ ctx := context.TODO()
+
+ req := new(dns.Msg)
+ req.SetQuestion("example.org.", dns.TypeA)
+
+ rec := dnstest.NewRecorder(&test.ResponseWriter{})
+ e.ServeDNS(ctx, rec, req)
+
+ if rec.Msg.Answer[0].Header().Rrtype != dns.TypeA {
+ t.Errorf("Expected A response, got %d type", rec.Msg.Answer[0].Header().Rrtype)
+ }
+}
diff --git a/plugin/erratic/setup.go b/plugin/erratic/setup.go
index 52c4d245c..79e4449ee 100644
--- a/plugin/erratic/setup.go
+++ b/plugin/erratic/setup.go
@@ -104,6 +104,8 @@ func parseErratic(c *caddy.Controller) (*Erratic, error) {
return nil, fmt.Errorf("illegal amount value given %q", args[0])
}
e.truncate = uint64(amount)
+ case "large":
+ e.large = true
default:
return nil, c.Errf("unknown property '%s'", c.Val())
}