From 4c86e546ac01746323bd45dd6d49febe4f16ba4c Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sat, 1 Dec 2018 09:07:42 +0000 Subject: [PATCH] plugin/forward: remove truncate logic (#2320) I think this is causing problem and it will actually clash with the scrubbing that now happens for all plugins anyway. We're assuming the returned message will be valid even with tc being set. request.Scrub follows that same logic. Signed-off-by: Miek Gieben --- plugin/forward/truncated_test.go | 121 ------------------------------- 1 file changed, 121 deletions(-) delete mode 100644 plugin/forward/truncated_test.go diff --git a/plugin/forward/truncated_test.go b/plugin/forward/truncated_test.go deleted file mode 100644 index 40fc8185f..000000000 --- a/plugin/forward/truncated_test.go +++ /dev/null @@ -1,121 +0,0 @@ -package forward - -import ( - "sync/atomic" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/pkg/transport" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestLookupTruncated(t *testing.T) { - i := int32(0) - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - j := atomic.LoadInt32(&i) - atomic.AddInt32(&i, 1) - - if j == 0 { - ret := new(dns.Msg) - ret.SetReply(r) - ret.Truncated = true - ret.Answer = append(ret.Answer, test.A("example.org. IN A 127.0.0.1")) - w.WriteMsg(ret) - return - - } - - ret := new(dns.Msg) - ret.SetReply(r) - ret.Answer = append(ret.Answer, test.A("example.org. IN A 127.0.0.1")) - w.WriteMsg(ret) - }) - defer s.Close() - - p := NewProxy(s.Addr, transport.DNS) - f := New() - f.SetProxy(p) - defer f.Close() - - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - - resp, err := f.Lookup(state, "example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - // expect answer with TC - if !resp.Truncated { - t.Error("Expected to receive reply with TC bit set, but didn't") - } - if len(resp.Answer) != 1 { - t.Error("Expected to receive original reply, but answer is missing") - } - - resp, err = f.Lookup(state, "example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - // expect answer without TC - if resp.Truncated { - t.Error("Expected to receive reply without TC bit set, but didn't") - } -} - -func TestForwardTruncated(t *testing.T) { - i := int32(0) - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - j := atomic.LoadInt32(&i) - atomic.AddInt32(&i, 1) - - if j == 0 { - ret := new(dns.Msg) - ret.SetReply(r) - ret.Truncated = true - ret.Answer = append(ret.Answer, test.A("example.org. IN A 127.0.0.1")) - w.WriteMsg(ret) - return - - } - - ret := new(dns.Msg) - ret.SetReply(r) - ret.Answer = append(ret.Answer, test.A("example.org. IN A 127.0.0.1")) - w.WriteMsg(ret) - }) - defer s.Close() - - f := New() - - p1 := NewProxy(s.Addr, transport.DNS) - f.SetProxy(p1) - p2 := NewProxy(s.Addr, transport.DNS) - f.SetProxy(p2) - defer f.Close() - - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - state.Req.SetQuestion("example.org.", dns.TypeA) - resp, err := f.Forward(state) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - - // expect answer with TC - if !resp.Truncated { - t.Error("Expected to receive reply with TC bit set, but didn't") - } - if len(resp.Answer) != 1 { - t.Error("Expected to receive original reply, but answer is missing") - } - - resp, err = f.Forward(state) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - // expect answer without TC - if resp.Truncated { - t.Error("Expected to receive reply without TC bit set, but didn't") - } -}