From 898b1ef31691fac4bc45ad507f6d5762555f4dea Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Tue, 23 Oct 2018 17:55:40 +0100 Subject: 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 * 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 * Fix tests Signed-off-by: Miek Gieben * 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 --- plugin/erratic/erratic.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'plugin/erratic/erratic.go') 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() -- cgit v1.2.3