Reported by Maoz Zadok
@@ -15,6 +15,7 @@
"a": [ [ "192.168.1.2", 10 ] ],
"ttl": "601"
},
+ "bar.no": { "a": [] },
"0": {
"a": [ [ "192.168.0.1", 10 ] ]
@@ -90,7 +90,7 @@ func (z *Zone) findLabels(s, cc string, qtype uint16) *Label {
// return the label if it has the right records
// TODO(ask) Should this also look for CNAME records?
- if label.Records[qtype] != nil {
+ if label.Records[qtype] != nil && len(label.Records[qtype]) > 0 {
return label
}
@@ -0,0 +1,15 @@
+package main
+
+import (
+ "github.com/miekg/dns"
+ . "launchpad.net/gocheck"
+)
+func (s *ConfigSuite) TestZone(c *C) {
+ ex := s.zones["example.com"]
+ c.Check(ex.Labels["weight"].MaxHosts, Equals, 1)
+ // Make sure that the empty "no.bar" zone gets skipped and "bar" is used
+ label := ex.findLabels("bar", "no", dns.TypeA)
+ c.Check(label.Records[dns.TypeA], HasLen, 1)
+}