Commit e671e22e authored by Tobias Schmidt's avatar Tobias Schmidt Committed by Miek Gieben

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.
parent 305ae9b9
...@@ -66,7 +66,7 @@ func (p *Proxy) connect(ctx context.Context, state request.Request, forceTCP, me ...@@ -66,7 +66,7 @@ func (p *Proxy) connect(ctx context.Context, state request.Request, forceTCP, me
if err == io.EOF && cached { if err == io.EOF && cached {
return nil, errCachedClosed return nil, errCachedClosed
} }
return nil, err return ret, err
} }
p.updateRtt(time.Since(reqTime)) p.updateRtt(time.Since(reqTime))
......
...@@ -49,6 +49,9 @@ func TestLookupTruncated(t *testing.T) { ...@@ -49,6 +49,9 @@ func TestLookupTruncated(t *testing.T) {
if !resp.Truncated { if !resp.Truncated {
t.Error("Expected to receive reply with TC bit set, but didn't") 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) resp, err = f.Lookup(state, "example.org.", dns.TypeA)
if err != nil { if err != nil {
...@@ -102,6 +105,9 @@ func TestForwardTruncated(t *testing.T) { ...@@ -102,6 +105,9 @@ func TestForwardTruncated(t *testing.T) {
if !resp.Truncated { if !resp.Truncated {
t.Error("Expected to receive reply with TC bit set, but didn't") 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) resp, err = f.Forward(state)
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment