From d61e2f573966836fe7f39067b1b31c0512e9bbaa Mon Sep 17 00:00:00 2001 From: Hiroyuki Wada Date: Thu, 1 Mar 2018 12:00:49 +0900 Subject: [PATCH] Fix handling not found record case --- amazondns.go | 28 ++++++++++++++-------------- build.sh | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/amazondns.go b/amazondns.go index 0bf269a..a713871 100644 --- a/amazondns.go +++ b/amazondns.go @@ -105,27 +105,27 @@ L: } func handleNotFound(zone *Zone, name string, m *dns.Msg) { + // Set authority m.Ns = []dns.RR{zone.soa} - if name == zone.soa.Header().Name { - m.Rcode = dns.RcodeSuccess - return - } - for _, ns := range zone.ns { - if name == ns.Header().Name { + if m.Rcode == dns.RcodeNameError { + if name == zone.soa.Header().Name { m.Rcode = dns.RcodeSuccess return } - } - for _, nsa := range zone.nsa { - if name == nsa.Header().Name { - m.Rcode = dns.RcodeSuccess - return + for _, ns := range zone.ns { + if name == ns.Header().Name { + m.Rcode = dns.RcodeSuccess + return + } + } + for _, nsa := range zone.nsa { + if name == nsa.Header().Name { + m.Rcode = dns.RcodeSuccess + return + } } } - - // Error - m.Rcode = dns.RcodeNameError } func resolveCNAME(reqName string, res *dns.Msg) { diff --git a/build.sh b/build.sh index 59ffb80..2d03bf3 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/bin/sh -VERSION=0.2 +VERSION=0.2.1 TAG=b1ce9ed6e5b6178fbfa73d3764d25a6e1f20fc82 CADDY_TAG=37b291f82c2083a378b698577640389686b0baf4 @@ -44,7 +44,7 @@ else go build cp coredns /go/src/github.com/wadahiro/coredns-amazondns/ - tar cvzf coredns-amazondns-$VERSION.tar.gz coredns - mv coredns-*.tar.gz /go/src/github.com/wadahiro/coredns-amazondns/ + tar cvzf coredns-amazondns_${VERSION}_linux-amd64.tgz coredns + mv coredns-*.tgz /go/src/github.com/wadahiro/coredns-amazondns/ fi