mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 00:04:15 -04:00
Up to DNS version 1.1.0 (#2346)
Upgrade to new dns lib version; that saw multiple improvements; some patch releases are in the pipeline. The big thing here is the removal of ErrTruncated, so we need to deal with this slightly different in the forward plugin. It removed the entire truncated.go logic and just checks the message for .Truncated (if there is a message) and retries with tcp. Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
2
Makefile
2
Makefile
@@ -31,7 +31,7 @@ godeps:
|
||||
go get -u github.com/prometheus/client_golang/prometheus/promhttp
|
||||
go get -u github.com/prometheus/client_golang/prometheus
|
||||
(cd $(GOPATH)/src/github.com/mholt/caddy && git checkout -q v0.11.1)
|
||||
(cd $(GOPATH)/src/github.com/miekg/dns && git checkout -q v1.0.15)
|
||||
(cd $(GOPATH)/src/github.com/miekg/dns && git checkout -q v1.1.0)
|
||||
(cd $(GOPATH)/src/github.com/prometheus/client_golang && git checkout -q v0.8.0)
|
||||
@ # for travis only, if this fails we don't care, but don't see benchmarks
|
||||
go get -u golang.org/x/tools/cmd/benchcmp || true
|
||||
|
||||
@@ -116,7 +116,7 @@ func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
|
||||
continue
|
||||
}
|
||||
// Retry with TCP if truncated and prefer_udp configured.
|
||||
if err == dns.ErrTruncated && !opts.forceTCP && f.opts.preferUDP {
|
||||
if ret != nil && ret.Truncated && !opts.forceTCP && f.opts.preferUDP {
|
||||
opts.forceTCP = true
|
||||
continue
|
||||
}
|
||||
@@ -127,7 +127,6 @@ func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
|
||||
child.Finish()
|
||||
}
|
||||
|
||||
ret, err = truncated(state, ret, err)
|
||||
upstreamErr = err
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -35,7 +35,6 @@ func (f *Forward) Forward(state request.Request) (*dns.Msg, error) {
|
||||
|
||||
ret, err := proxy.Connect(context.Background(), state, f.opts)
|
||||
|
||||
ret, err = truncated(state, ret, err)
|
||||
upstreamErr = err
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package forward
|
||||
|
||||
import (
|
||||
"github.com/coredns/coredns/request"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
// truncated looks at the error and if truncated return a nil error
|
||||
// and a possible reconstructed dns message if that was nil.
|
||||
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.
|
||||
if err != dns.ErrTruncated {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// We may or may not have something sensible... if not reassemble something to send to the client.
|
||||
m := ret
|
||||
if ret == nil {
|
||||
m = new(dns.Msg)
|
||||
m.SetReply(state.Req)
|
||||
m.Truncated = true
|
||||
m.Authoritative = true
|
||||
m.Rcode = dns.RcodeSuccess
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
Reference in New Issue
Block a user