plugin/forward: check TC correctly on reply. (#1670)
* plugin/forward: check TC correctly on reply. Add test for this. * Add proxy test as well
This commit is contained in:
parent
9ae9ee4b6b
commit
305ae9b9bc
4 changed files with 123 additions and 5 deletions
|
@ -1,10 +1,14 @@
|
|||
package forward
|
||||
|
||||
import "github.com/miekg/dns"
|
||||
import (
|
||||
"github.com/coredns/coredns/request"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
// truncated looks at the error and if truncated return a nil errror
|
||||
// and a possible reconstructed dns message if that was nil.
|
||||
func truncated(ret *dns.Msg, err error) (*dns.Msg, error) {
|
||||
func truncated(state request.Request, ret *dns.Msg, err error) (*dns.Msg, error) {
|
||||
// If you query for instance ANY isc.org; you get a truncated query back which miekg/dns fails to unpack
|
||||
// because the RRs are not finished. The returned message can be useful or useless. Return the original
|
||||
// query with some header bits set that they should retry with TCP.
|
||||
|
@ -16,7 +20,7 @@ func truncated(ret *dns.Msg, err error) (*dns.Msg, error) {
|
|||
m := ret
|
||||
if ret == nil {
|
||||
m = new(dns.Msg)
|
||||
m.SetReply(ret)
|
||||
m.SetReply(state.Req)
|
||||
m.Truncated = true
|
||||
m.Authoritative = true
|
||||
m.Rcode = dns.RcodeSuccess
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue