diff options
author | 2018-04-12 21:17:05 +0200 | |
---|---|---|
committer | 2018-04-12 20:17:05 +0100 | |
commit | e671e22e657b2fcb1580abd311e9c340b20b9e96 (patch) | |
tree | 8b7217f3a91ff2efca75bf5c963745d8da850d03 | |
parent | 305ae9b9bcade8c1a7b58b091b6fa2accf455a77 (diff) | |
download | coredns-e671e22e657b2fcb1580abd311e9c340b20b9e96.tar.gz coredns-e671e22e657b2fcb1580abd311e9c340b20b9e96.tar.zst coredns-e671e22e657b2fcb1580abd311e9c340b20b9e96.zip |
plugin/forward: Return original message on truncation (#1674)
With this change the original truncated message returned by requested
server is returned to the client, instead of returning an empty dummy
message with only the truncation bit set.
-rw-r--r-- | plugin/forward/connect.go | 2 | ||||
-rw-r--r-- | plugin/forward/truncated_test.go | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/plugin/forward/connect.go b/plugin/forward/connect.go index 13631ca89..9dd6ac855 100644 --- a/plugin/forward/connect.go +++ b/plugin/forward/connect.go @@ -66,7 +66,7 @@ func (p *Proxy) connect(ctx context.Context, state request.Request, forceTCP, me if err == io.EOF && cached { return nil, errCachedClosed } - return nil, err + return ret, err } p.updateRtt(time.Since(reqTime)) diff --git a/plugin/forward/truncated_test.go b/plugin/forward/truncated_test.go index 4d8a0a25e..1c9e92a07 100644 --- a/plugin/forward/truncated_test.go +++ b/plugin/forward/truncated_test.go @@ -49,6 +49,9 @@ func TestLookupTruncated(t *testing.T) { 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 { @@ -102,6 +105,9 @@ func TestForwardTruncated(t *testing.T) { 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 { |