From 83958561f731e640981ae5927005f2841a4d0045 Mon Sep 17 00:00:00 2001 From: Topper Bowers Date: Mon, 27 Feb 2017 12:15:12 +0100 Subject: [PATCH 1/2] some DNS clients send reverse lookups with uppercase suffixes. This lowercases the request before trimming the lowercase suffix. Problem discovered and discussed here: https://github.com/weaveworks/weave/issues/2817 --- nameserver/dns.go | 2 +- test/245_dns_case_insensitive_test.sh | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/nameserver/dns.go b/nameserver/dns.go index eb35584b..f2cd8fe7 100644 --- a/nameserver/dns.go +++ b/nameserver/dns.go @@ -222,7 +222,7 @@ func (h *handler) handleReverse(w dns.ResponseWriter, req *dns.Msg) { return } - ipStr := strings.TrimSuffix(req.Question[0].Name, "."+reverseDNSdomain) + ipStr := strings.TrimSuffix(strings.ToLower(req.Question[0].Name), "."+reverseDNSdomain) ip, err := address.ParseIP(ipStr) if err != nil { h.nameError(w, req) diff --git a/test/245_dns_case_insensitive_test.sh b/test/245_dns_case_insensitive_test.sh index 47208833..9c05f1af 100755 --- a/test/245_dns_case_insensitive_test.sh +++ b/test/245_dns_case_insensitive_test.sh @@ -6,6 +6,9 @@ C1=10.2.0.78 C2=10.2.0.79 C3=10.2.0.80 +REVERSE_C1_LOWER=78.0.2.10.in-addr.arpa +REVERSE_C1_UPPER=78.0.2.10.IN-ADDR.ARPA + start_suite "DNS lookup case (in)sensitivity" weave_on $HOST1 launch @@ -17,6 +20,9 @@ assert_dns_record $HOST1 test seeone.weave.local $C1 assert_dns_record $HOST1 test SeeOne.weave.local $C1 assert_dns_record $HOST1 test SEEONE.weave.local $C1 +assert_dns_record $HOST1 test $REVERSE_C1_LOWER seeone.weave.local +assert_dns_record $HOST1 test $REVERSE_C1_UPPER seeone.weave.local + start_container $HOST1 $C2/24 --name=SeEtWo assert_dns_record $HOST1 test seetwo.weave.local $C2 assert_dns_record $HOST1 test SeeTwo.weave.local $C2 From e57d79bd709fe00717b74453da0bde7f0c8e269e Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 27 Feb 2017 14:21:59 +0000 Subject: [PATCH 2/2] Test reverse DNS using dig so that we can check it works with upper and lower case IN-ADDR.ARPA --- test/245_dns_case_insensitive_test.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/245_dns_case_insensitive_test.sh b/test/245_dns_case_insensitive_test.sh index 9c05f1af..0e55268b 100755 --- a/test/245_dns_case_insensitive_test.sh +++ b/test/245_dns_case_insensitive_test.sh @@ -20,8 +20,9 @@ assert_dns_record $HOST1 test seeone.weave.local $C1 assert_dns_record $HOST1 test SeeOne.weave.local $C1 assert_dns_record $HOST1 test SEEONE.weave.local $C1 -assert_dns_record $HOST1 test $REVERSE_C1_LOWER seeone.weave.local -assert_dns_record $HOST1 test $REVERSE_C1_UPPER seeone.weave.local +# Test reverse DNS using explicit in-addr.arpa format, lower and upper case +assert "exec_on $HOST1 test dig +short -t PTR $REVERSE_C1_LOWER" seeone.weave.local. +assert "exec_on $HOST1 test dig +short -t PTR $REVERSE_C1_UPPER" seeone.weave.local. start_container $HOST1 $C2/24 --name=SeEtWo assert_dns_record $HOST1 test seetwo.weave.local $C2