diff --git a/plugin/forward/forward.go b/plugin/forward/forward.go index c7f7a83c4..da2e175fe 100644 --- a/plugin/forward/forward.go +++ b/plugin/forward/forward.go @@ -146,7 +146,8 @@ func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg if !state.Match(ret) { debug.Hexdumpf(ret, "Wrong reply for id: %d, %s %d", ret.Id, state.QName(), state.QType()) - formerr := state.ErrorMessage(dns.RcodeFormatError) + formerr := new(dns.Msg) + formerr.SetRcode(state.Req, dns.RcodeFormatError) w.WriteMsg(formerr) return 0, taperr } diff --git a/plugin/grpc/grpc.go b/plugin/grpc/grpc.go index 655be00c1..3dda225df 100644 --- a/plugin/grpc/grpc.go +++ b/plugin/grpc/grpc.go @@ -77,7 +77,8 @@ func (g *GRPC) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ( if !state.Match(ret) { debug.Hexdumpf(ret, "Wrong reply for id: %d, %s %d", ret.Id, state.QName(), state.QType()) - formerr := state.ErrorMessage(dns.RcodeFormatError) + formerr := new(dns.Msg) + formerr.SetRcode(state.Req, dns.RcodeFormatError) w.WriteMsg(formerr) return 0, nil } diff --git a/request/request.go b/request/request.go index f9dddda93..bd107c9ee 100644 --- a/request/request.go +++ b/request/request.go @@ -433,14 +433,6 @@ func (r *Request) QClass() uint16 { } -// ErrorMessage returns an error message suitable for sending -// back to the client. -func (r *Request) ErrorMessage(rcode int) *dns.Msg { - m := new(dns.Msg) - m.SetRcode(r.Req, rcode) - return m -} - // Clear clears all caching from Request s. func (r *Request) Clear() { r.name = ""