]> granicus.if.org Git - pdns/commitdiff
Rectify records
authorAki Tuomi <cmouse@cmouse.fi>
Fri, 11 Sep 2015 09:17:12 +0000 (12:17 +0300)
committerAki Tuomi <cmouse@cmouse.fi>
Fri, 11 Sep 2015 09:17:12 +0000 (12:17 +0300)
modules/geoipbackend/geoipbackend.cc

index 2e7d2acc728b61098356ce71f969d27439b705c9..c3edfa419ab27867ee4a614e58e0e09746e1cd76 100644 (file)
@@ -121,6 +121,48 @@ void GeoIPBackend::initialize() {
       dom.services[DNSName(service->first.as<string>())] = service->second.as<string>();
     }
 
+    // rectify the zone, first static records
+    for(auto &item : dom.records) {
+      // ensure we have parent in records
+      DNSName name = item.first;
+      while(name.chopOff() && name.isPartOf(dom.domain)) {
+        if (dom.records.find(name) == dom.records.end()) {
+          DNSResourceRecord rr;
+          vector<DNSResourceRecord> rrs;
+          rr.domain_id = dom.id;
+          rr.ttl = dom.ttl;
+          rr.qname = name;
+          rr.qtype = "NULL";
+          rr.content = "";
+          rr.auth = 1;
+          rr.d_place = DNSResourceRecord::ANSWER;
+          rrs.push_back(rr);
+          std::swap(dom.records[name], rrs);
+        }
+      }
+    }
+
+    // then services
+    for(auto &item : dom.services) {
+      // ensure we have parent in records
+      DNSName name = item.first;
+      while(name.chopOff() && name.isPartOf(dom.domain)) {
+        if (dom.records.find(name) == dom.records.end()) {
+          DNSResourceRecord rr;
+          vector<DNSResourceRecord> rrs;
+          rr.domain_id = dom.id;
+          rr.ttl = dom.ttl;
+          rr.qname = name;
+          rr.qtype = "NULL";
+          rr.content = "";
+          rr.auth = 1;
+          rr.d_place = DNSResourceRecord::ANSWER;
+          rrs.push_back(rr);
+          std::swap(dom.records[name], rrs);
+        }
+      }
+    }
+
     tmp_domains.push_back(dom);
   }