Merge pull request #348 from squaremo/issue346_fallback_for_rdns

LGTM.  Closes #346.
This commit is contained in:
Bryan Boreham committed 2015-01-15 15:31:49 +00:00
commit 92043a3dbc
4 files changed
+23 -8

No files matched your search

+4 -4
View File
@@ -51,6 +51,7 @@ func queryHandler(lookups []Lookup) dns.HandlerFunc {
}
func rdnsHandler(lookups []Lookup) dns.HandlerFunc {
fallback := notUsHandler()
return func(w dns.ResponseWriter, r *dns.Msg) {
q := r.Question[0]
Debug.Printf("Reverse query: %+v", q)
@@ -62,13 +63,12 @@ func rdnsHandler(lookups []Lookup) dns.HandlerFunc {
return
}
}
Info.Printf("[dns msgid %d] No results for type %s query %s",
r.MsgHdr.Id, dns.TypeToString[q.Qtype], q.Name)
fallback(w, r)
return
} else {
Warning.Printf("[dns msgid %d] Unexpected reverse query type %s: %+v",
r.MsgHdr.Id, dns.TypeToString[q.Qtype], q)
}
w.WriteMsg(makeDNSFailResponse(r))
}
}
@@ -80,7 +80,7 @@ func notUsHandler() dns.HandlerFunc {
checkFatal(err)
return func(w dns.ResponseWriter, r *dns.Msg) {
q := r.Question[0]
Debug.Printf("[dns msgid %d] Non-local query: %+v", r.MsgHdr.Id, q)
Debug.Printf("[dns msgid %d] Fallback query: %+v", r.MsgHdr.Id, q)
for _, server := range config.Servers {
reply, err := dns.Exchange(r, fmt.Sprintf("%s:%s", server, config.Port))
if err != nil {
+10 -1
View File
@@ -78,5 +78,14 @@ func TestDNSServer(t *testing.T) {
t.Fatal("Number of answers > 0")
}
// Not testing MDNS functionality of server here (yet)
m.SetQuestion("8.8.8.8.in-addr.arpa.", dns.TypePTR)
r, _, err = c.Exchange(m, dnsAddr)
wt.AssertNoErr(t, err)
wt.AssertStatus(t, r.Rcode, dns.RcodeSuccess, "DNS success response code")
if !(len(r.Answer) > 0) {
t.Fatal("Number of answers > 0")
}
// Not testing MDNS functionality of server here (yet), since it
// needs two servers, each listening on its own address
}
+5 -2
View File
@@ -16,8 +16,8 @@ done
run_on $HOST1 sudo $WEAVE launch
run_on $HOST2 sudo $WEAVE launch $HOST1
run_on $HOST1 sudo $WEAVE launch-dns 10.0.0.2/8
run_on $HOST2 sudo $WEAVE launch-dns 10.0.0.3/8
run_on $HOST1 sudo $WEAVE launch-dns 10.3.3.2/24 -debug
run_on $HOST2 sudo $WEAVE launch-dns 10.3.3.3/24 -debug
run_on $HOST2 sudo $WEAVE run $C2/24 -t --name=c2 -h seetwo.weave.local ubuntu
run_on $HOST1 sudo $WEAVE run --with-dns $C1/24 --name=c1 -t aanand/docker-dnsutils /bin/sh
@@ -28,4 +28,7 @@ assert "echo $ok" "$C2"
ok=$(docker -H tcp://$HOST1:2375 exec -i c1 dig +short -x $C2)
assert "echo $ok" "seetwo.weave.local."
ok=$(docker -H tcp://$HOST1:2375 exec -i c1 dig +short -x 8.8.8.8)
assert "test -n \"$ok\" && echo pass" "pass"
end_suite
+4 -1
View File
@@ -5,7 +5,7 @@
start_suite "Resolve a non-weave address"
run_on $HOST1 sudo $WEAVE stop-dns || true
run_on $HOST1 sudo $WEAVE launch-dns 10.0.0.2
run_on $HOST1 sudo $WEAVE launch-dns 10.2.6.2 -debug
docker_on $HOST1 rm -f c1 || true
run_on $HOST1 sudo $WEAVE run --with-dns 10.1.1.5/24 --name=c1 -t aanand/docker-dnsutils /bin/sh
@@ -13,4 +13,7 @@ run_on $HOST1 sudo $WEAVE run --with-dns 10.1.1.5/24 --name=c1 -t aanand/docker-
ok=$(docker -H tcp://$HOST1:2375 exec -i c1 dig +short -t MX weave.works)
assert "test -n \"$ok\" && echo pass" "pass"
ok=$(docker -H tcp://$HOST1:2375 exec -i c1 dig +short -x 8.8.8.8)
assert "test -n \"$ok\" && echo pass" "pass"
end_suite