Permalink
Browse files

Rectify records

  • Loading branch information...
1 parent 69ea1a6 commit 77365305751372e1fe5544bdd5bca7e24c7b8b9a @cmouse cmouse committed Sep 11, 2015
Showing with 42 additions and 0 deletions.
  1. +42 −0 modules/geoipbackend/geoipbackend.cc
@@ -128,6 +128,48 @@ void GeoIPBackend::initialize() {
dom.services[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);
}

0 comments on commit 7736530

Please sign in to comment.