aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2018-12-01 09:07:42 +0000
committerGravatar GitHub <noreply@github.com> 2018-12-01 09:07:42 +0000
commit4c86e546ac01746323bd45dd6d49febe4f16ba4c (patch)
tree904ee3a3162e913fd0b899a6f0d74819b34b0a1c /plugin
parentbae9514e94af2efec2568f0d769b0b036b766c80 (diff)
downloadcoredns-4c86e546ac01746323bd45dd6d49febe4f16ba4c.tar.gz
coredns-4c86e546ac01746323bd45dd6d49febe4f16ba4c.tar.zst
coredns-4c86e546ac01746323bd45dd6d49febe4f16ba4c.zip
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 <miek@miek.nl>
Diffstat (limited to 'plugin')
-rw-r--r--plugin/forward/truncated_test.go121
1 files changed, 0 insertions, 121 deletions
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")
- }
-}