From 8d24fb90601fec487b4928810f9c36e2b4aa6a74 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Tue, 8 May 2018 19:55:35 +0300 Subject: [PATCH] geoipbackend: Add struct for holding geoip service --- modules/geoipbackend/geoipbackend.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/geoipbackend/geoipbackend.cc b/modules/geoipbackend/geoipbackend.cc index a3a7ad498..a955354f8 100644 --- a/modules/geoipbackend/geoipbackend.cc +++ b/modules/geoipbackend/geoipbackend.cc @@ -39,11 +39,15 @@ struct GeoIPDNSResourceRecord: DNSResourceRecord { bool has_weight; }; +struct GeoIPService { + NetmaskTree > masks; +}; + struct GeoIPDomain { int id; DNSName domain; int ttl; - map > > services; + map services; map > 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())].swap(nmt); + dom.services[DNSName(service->first.as())].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 >::node_type* node = target->second.lookup(ComboAddress(ip)); + const NetmaskTree >::node_type* node = target->second.masks.lookup(ComboAddress(ip)); if (node == NULL) return; // no hit, again. DNSName sformat; -- 2.40.0