]> granicus.if.org Git - pdns/commitdiff
geoipbackend: Add struct for holding geoip service
authorAki Tuomi <cmouse@cmouse.fi>
Tue, 8 May 2018 16:55:35 +0000 (19:55 +0300)
committerAki Tuomi <cmouse@cmouse.fi>
Tue, 8 May 2018 16:55:35 +0000 (19:55 +0300)
modules/geoipbackend/geoipbackend.cc

index a3a7ad498a071420c02f6e56f3fa90179a10504f..a955354f8fa577e24fdcc26f907410981e09246c 100644 (file)
@@ -39,11 +39,15 @@ struct GeoIPDNSResourceRecord: DNSResourceRecord {
   bool has_weight;
 };
 
+struct GeoIPService {
+  NetmaskTree<vector<string> > masks;
+};
+
 struct GeoIPDomain {
   int id;
   DNSName domain;
   int ttl;
-  map<DNSName, NetmaskTree<vector<string> > > services;
+  map<DNSName, GeoIPService> services;
   map<DNSName, vector<GeoIPDNSResourceRecord> > records;
 };
 
@@ -190,7 +194,7 @@ void GeoIPBackend::initialize() {
         nmt.insert(Netmask("0.0.0.0/0")).second.assign(value.begin(),value.end());
         nmt.insert(Netmask("::/0")).second.swap(value);
       }
-      dom.services[DNSName(service->first.as<string>())].swap(nmt);
+      dom.services[DNSName(service->first.as<string>())].masks.swap(nmt);
     }
 
     // rectify the zone, first static records
@@ -355,7 +359,7 @@ void GeoIPBackend::lookup(const QType &qtype, const DNSName& qdomain, DNSPacket
   auto target = dom.services.find(search);
   if (target == dom.services.end()) return; // no hit
 
-  const NetmaskTree<vector<string> >::node_type* node = target->second.lookup(ComboAddress(ip));
+  const NetmaskTree<vector<string> >::node_type* node = target->second.masks.lookup(ComboAddress(ip));
   if (node == NULL) return; // no hit, again.
 
   DNSName sformat;