Commit 50ef7409 authored by Miek Gieben's avatar Miek Gieben Committed by GitHub

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: default avatarMiek Gieben <miek@miek.nl>
parent 39ad7e49
...@@ -31,7 +31,7 @@ godeps: ...@@ -31,7 +31,7 @@ godeps:
go get -u github.com/prometheus/client_golang/prometheus/promhttp go get -u github.com/prometheus/client_golang/prometheus/promhttp
go get -u github.com/prometheus/client_golang/prometheus 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/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) (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 @ # 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 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 ...@@ -116,7 +116,7 @@ func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
continue continue
} }
// Retry with TCP if truncated and prefer_udp configured. // 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 opts.forceTCP = true
continue continue
} }
...@@ -127,7 +127,6 @@ func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg ...@@ -127,7 +127,6 @@ func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
child.Finish() child.Finish()
} }
ret, err = truncated(state, ret, err)
upstreamErr = err upstreamErr = err
if err != nil { if err != nil {
......
...@@ -35,7 +35,6 @@ func (f *Forward) Forward(state request.Request) (*dns.Msg, error) { ...@@ -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 := proxy.Connect(context.Background(), state, f.opts)
ret, err = truncated(state, ret, err)
upstreamErr = err upstreamErr = err
if err != nil { if err != nil {
......
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
}
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