aboutsummaryrefslogtreecommitdiff
path: root/plugin/erratic/erratic.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2018-10-23 17:55:40 +0100
committerGravatar John Belamaric <jbelamaric@google.com> 2018-10-23 09:55:40 -0700
commit898b1ef31691fac4bc45ad507f6d5762555f4dea (patch)
tree688a8c6b1a994c09f6b50ed3c6ef9ad68a5321fb /plugin/erratic/erratic.go
parent96529b2c501b47a71a0f6eae5a04ebe86ba1ab1d (diff)
downloadcoredns-898b1ef31691fac4bc45ad507f6d5762555f4dea.tar.gz
coredns-898b1ef31691fac4bc45ad507f6d5762555f4dea.tar.zst
coredns-898b1ef31691fac4bc45ad507f6d5762555f4dea.zip
server: actually scrub response (#2225)
* server: actually scrub response Did all the worked, hooked it up wrongly :( This also needs test, but those are hard(er) because we only receive packets after they have been decoded; i.e. we never see the wirefmt. Signed-off-by: Miek Gieben <miek@miek.nl> * Add tests Add a test for checking is compression pointers are set in the packet. This also adds an undocumented 'large' feature to the erratic plugin to send large responses that should be compressed. Commenting the Scrub out in server results in: === RUN TestCompressScrub --- FAIL: TestCompressScrub (0.00s) compression_scrub_test.go:41: Expected returned packet to be < 512, got 839 FAIL exit status 1 FAIL github.com/coredns/coredns/test 0.036s Actually checking the size might be easier, but lets be thorough here and check the pointers them selves. Signed-off-by: Miek Gieben <miek@miek.nl> * Fix tests Signed-off-by: Miek Gieben <miek@miek.nl> * plugin erratic: fix e.large always put an rr in the reply, fix e.large in erractic and add test to check for it. Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/erratic/erratic.go')
-rw-r--r--plugin/erratic/erratic.go6
1 files changed, 6 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()