From: Aki Tuomi Date: Sat, 30 Dec 2017 15:52:54 +0000 (+0200) Subject: geoipbackend: Replace GeoIPLookup with GeoIPNetmask X-Git-Tag: dnsdist-1.3.0~85^2~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=23c4de63a99b44b6b4573ee6a07d85308b08cb33;p=pdns geoipbackend: Replace GeoIPLookup with GeoIPNetmask GeoIPLookup is part of GeoIP library, and is not necessarely available on future interfaces, so replace it with our own structure for same purpose. This makes it possible to add indepedent interfaces. --- diff --git a/modules/geoipbackend/geoipbackend.cc b/modules/geoipbackend/geoipbackend.cc index 6ed40cd62..25a685929 100644 --- a/modules/geoipbackend/geoipbackend.cc +++ b/modules/geoipbackend/geoipbackend.cc @@ -279,7 +279,7 @@ GeoIPBackend::~GeoIPBackend() { } } -bool GeoIPBackend::lookup_static(const GeoIPDomain &dom, const DNSName &search, const QType &qtype, const DNSName& qdomain, const std::string &ip, GeoIPLookup &gl, bool v6) { +bool GeoIPBackend::lookup_static(const GeoIPDomain &dom, const DNSName &search, const QType &qtype, const DNSName& qdomain, const std::string &ip, GeoIPNetmask &gl, bool v6) { const auto i = dom.records.find(search); int cumul_probability = 0; int probability_rnd = 1+(dns_random(1000)); // setting probability=0 means it never is used @@ -295,7 +295,7 @@ bool GeoIPBackend::lookup_static(const GeoIPDomain &dom, const DNSName &search, } if (qtype == QType::ANY || rr.qtype == qtype) { d_result.push_back(rr); - d_result.back().content = format2str(rr.content, ip, v6, &gl); + d_result.back().content = format2str(rr.content, ip, v6, gl); d_result.back().qname = qdomain; } } @@ -312,7 +312,7 @@ bool GeoIPBackend::lookup_static(const GeoIPDomain &dom, const DNSName &search, void GeoIPBackend::lookup(const QType &qtype, const DNSName& qdomain, DNSPacket *pkt_p, int zoneId) { ReadLock rl(&s_state_lock); GeoIPDomain dom; - GeoIPLookup gl; + GeoIPNetmask gl; bool found = false; if (d_result.size()>0) @@ -357,7 +357,7 @@ void GeoIPBackend::lookup(const QType &qtype, const DNSName& qdomain, DNSPacket // note that this means the array format won't work with indirect for(auto it = node->second.begin(); it != node->second.end(); it++) { - sformat = DNSName(format2str(*it, ip, v6, &gl)); + sformat = DNSName(format2str(*it, ip, v6, gl)); // see if the record can be found if (this->lookup_static(dom, sformat, qtype, qdomain, ip, gl, v6)) @@ -396,7 +396,7 @@ bool GeoIPBackend::get(DNSResourceRecord &r) { return true; } -string queryGeoIP(const string &ip, bool v6, GeoIPInterface::GeoIPQueryAttribute attribute, GeoIPLookup* gl) { +string queryGeoIP(const string &ip, bool v6, GeoIPInterface::GeoIPQueryAttribute attribute, GeoIPNetmask& gl) { string ret = "unknown"; for(auto const& gi: s_geoip_files) { @@ -440,14 +440,14 @@ string queryGeoIP(const string &ip, bool v6, GeoIPInterface::GeoIPQueryAttribute break; } - if (ret == "unknown") gl->netmask = (v6?128:32); // prevent caching + if (ret == "unknown") gl.netmask = (v6?128:32); // prevent caching return ret; } -string GeoIPBackend::format2str(string sformat, const string& ip, bool v6, GeoIPLookup* gl) { +string GeoIPBackend::format2str(string sformat, const string& ip, bool v6, GeoIPNetmask& gl) { string::size_type cur,last; time_t t = time((time_t*)NULL); - GeoIPLookup tmp_gl; // largest wins + GeoIPNetmask tmp_gl; // largest wins struct tm gtm; gmtime_r(&t, >m); last=0; @@ -457,21 +457,21 @@ string GeoIPBackend::format2str(string sformat, const string& ip, bool v6, GeoIP int nrep=3; tmp_gl.netmask = 0; if (!sformat.compare(cur,3,"%cn")) { - rep = queryGeoIP(ip, v6, GeoIPInterface::Continent, &tmp_gl); + rep = queryGeoIP(ip, v6, GeoIPInterface::Continent, tmp_gl); } else if (!sformat.compare(cur,3,"%co")) { - rep = queryGeoIP(ip, v6, GeoIPInterface::Country, &tmp_gl); + rep = queryGeoIP(ip, v6, GeoIPInterface::Country, tmp_gl); } else if (!sformat.compare(cur,3,"%cc")) { - rep = queryGeoIP(ip, v6, GeoIPInterface::Country2, &tmp_gl); + rep = queryGeoIP(ip, v6, GeoIPInterface::Country2, tmp_gl); } else if (!sformat.compare(cur,3,"%af")) { rep = (v6?"v6":"v4"); } else if (!sformat.compare(cur,3,"%as")) { - rep = queryGeoIP(ip, v6, GeoIPInterface::ASn, &tmp_gl); + rep = queryGeoIP(ip, v6, GeoIPInterface::ASn, tmp_gl); } else if (!sformat.compare(cur,3,"%re")) { - rep = queryGeoIP(ip, v6, GeoIPInterface::Region, &tmp_gl); + rep = queryGeoIP(ip, v6, GeoIPInterface::Region, tmp_gl); } else if (!sformat.compare(cur,3,"%na")) { - rep = queryGeoIP(ip, v6, GeoIPInterface::Name, &tmp_gl); + rep = queryGeoIP(ip, v6, GeoIPInterface::Name, tmp_gl); } else if (!sformat.compare(cur,3,"%ci")) { - rep = queryGeoIP(ip, v6, GeoIPInterface::City, &tmp_gl); + rep = queryGeoIP(ip, v6, GeoIPInterface::City, tmp_gl); } else if (!sformat.compare(cur,3,"%hh")) { rep = boost::str(boost::format("%02d") % gtm.tm_hour); tmp_gl.netmask = (v6?128:32); @@ -503,7 +503,7 @@ string GeoIPBackend::format2str(string sformat, const string& ip, bool v6, GeoIP } else { last = cur + 1; continue; } - if (tmp_gl.netmask > gl->netmask) gl->netmask = tmp_gl.netmask; + if (tmp_gl.netmask > gl.netmask) gl.netmask = tmp_gl.netmask; sformat.replace(cur, nrep, rep); last = cur + rep.size(); // move to next attribute } diff --git a/modules/geoipbackend/geoipbackend.hh b/modules/geoipbackend/geoipbackend.hh index 9ebe3b5f5..b872f06c9 100644 --- a/modules/geoipbackend/geoipbackend.hh +++ b/modules/geoipbackend/geoipbackend.hh @@ -45,6 +45,10 @@ class GeoIPInterface; class GeoIPDomain; +struct GeoIPNetmask { + int netmask; +}; + class GeoIPBackend: public DNSBackend { public: GeoIPBackend(const std::string& suffix=""); @@ -71,10 +75,10 @@ private: static pthread_rwlock_t s_state_lock; void initialize(); - string format2str(string format, const string& ip, bool v6, GeoIPLookup* gl); + string format2str(string format, const string& ip, bool v6, GeoIPNetmask& gl); bool d_dnssec; bool hasDNSSECkey(const DNSName& name); - bool lookup_static(const GeoIPDomain &dom, const DNSName &search, const QType &qtype, const DNSName& qdomain, const std::string &ip, GeoIPLookup &gl, bool v6); + bool lookup_static(const GeoIPDomain &dom, const DNSName &search, const QType &qtype, const DNSName& qdomain, const std::string &ip, GeoIPNetmask& gl, bool v6); vector d_result; vector d_files; }; diff --git a/modules/geoipbackend/geoipinterface-dat.cc b/modules/geoipbackend/geoipinterface-dat.cc index 8ced5c72a..a59266f9b 100644 --- a/modules/geoipbackend/geoipinterface-dat.cc +++ b/modules/geoipbackend/geoipinterface-dat.cc @@ -55,15 +55,20 @@ public: d_db_type = GeoIP_database_edition(d_gi.get()); } - bool queryCountry(string &ret, GeoIPLookup* gl, const string &ip) override { + bool queryCountry(string &ret, GeoIPNetmask& gl, const string &ip) override { + GeoIPLookup tmp_gl = { + .netmask = gl.netmask, + }; if (d_db_type == GEOIP_COUNTRY_EDITION || d_db_type == GEOIP_LARGE_COUNTRY_EDITION) { - ret = GeoIP_code3_by_id(GeoIP_id_by_addr_gl(d_gi.get(), ip.c_str(), gl)); + ret = GeoIP_code3_by_id(GeoIP_id_by_addr_gl(d_gi.get(), ip.c_str(), &tmp_gl)); + gl.netmask = tmp_gl.netmask; return true; } else if (d_db_type == GEOIP_REGION_EDITION_REV0 || d_db_type == GEOIP_REGION_EDITION_REV1) { - GeoIPRegion* gir = GeoIP_region_by_addr_gl(d_gi.get(), ip.c_str(), gl); + GeoIPRegion* gir = GeoIP_region_by_addr_gl(d_gi.get(), ip.c_str(), &tmp_gl); if (gir) { + gl.netmask = tmp_gl.netmask; ret = GeoIP_code3_by_id(GeoIP_id_by_code(gir->country_code)); return true; } @@ -72,22 +77,27 @@ public: GeoIPRecord *gir = GeoIP_record_by_addr(d_gi.get(), ip.c_str()); if (gir) { ret = gir->country_code3; - gl->netmask = gir->netmask; + gl.netmask = gir->netmask; return true; } } return false; } - bool queryCountryV6(string &ret, GeoIPLookup* gl, const string &ip) override { + bool queryCountryV6(string &ret, GeoIPNetmask& gl, const string &ip) override { + GeoIPLookup tmp_gl = { + .netmask = gl.netmask, + }; if (d_db_type == GEOIP_COUNTRY_EDITION_V6 || d_db_type == GEOIP_LARGE_COUNTRY_EDITION_V6) { - ret = GeoIP_code3_by_id(GeoIP_id_by_addr_v6_gl(d_gi.get(), ip.c_str(), gl)); + ret = GeoIP_code3_by_id(GeoIP_id_by_addr_v6_gl(d_gi.get(), ip.c_str(), &tmp_gl)); + gl.netmask = tmp_gl.netmask; return true; } else if (d_db_type == GEOIP_REGION_EDITION_REV0 || d_db_type == GEOIP_REGION_EDITION_REV1) { - GeoIPRegion* gir = GeoIP_region_by_addr_v6_gl(d_gi.get(), ip.c_str(), gl); + GeoIPRegion* gir = GeoIP_region_by_addr_v6_gl(d_gi.get(), ip.c_str(), &tmp_gl); if (gir) { + gl.netmask = tmp_gl.netmask; ret = GeoIP_code3_by_id(GeoIP_id_by_code(gir->country_code)); return true; } @@ -96,22 +106,27 @@ public: GeoIPRecord *gir = GeoIP_record_by_addr_v6(d_gi.get(), ip.c_str()); if (gir) { ret = gir->country_code3; - gl->netmask = gir->netmask; + gl.netmask = gir->netmask; return true; } } return false; } - bool queryCountry2(string &ret, GeoIPLookup* gl, const string &ip) override { + bool queryCountry2(string &ret, GeoIPNetmask& gl, const string &ip) override { + GeoIPLookup tmp_gl = { + .netmask = gl.netmask, + }; if (d_db_type == GEOIP_COUNTRY_EDITION || d_db_type == GEOIP_LARGE_COUNTRY_EDITION) { - ret = GeoIP_code_by_id(GeoIP_id_by_addr_gl(d_gi.get(), ip.c_str(), gl)); + ret = GeoIP_code_by_id(GeoIP_id_by_addr_gl(d_gi.get(), ip.c_str(), &tmp_gl)); + gl.netmask = tmp_gl.netmask; return true; } else if (d_db_type == GEOIP_REGION_EDITION_REV0 || d_db_type == GEOIP_REGION_EDITION_REV1) { - GeoIPRegion* gir = GeoIP_region_by_addr_gl(d_gi.get(), ip.c_str(), gl); + GeoIPRegion* gir = GeoIP_region_by_addr_gl(d_gi.get(), ip.c_str(), &tmp_gl); if (gir) { + gl.netmask = tmp_gl.netmask; ret = GeoIP_code_by_id(GeoIP_id_by_code(gir->country_code)); return true; } @@ -120,22 +135,27 @@ public: GeoIPRecord *gir = GeoIP_record_by_addr(d_gi.get(), ip.c_str()); if (gir) { ret = gir->country_code; - gl->netmask = gir->netmask; + gl.netmask = gir->netmask; return true; } } return false; } - bool queryCountry2V6(string &ret, GeoIPLookup* gl, const string &ip) override { + bool queryCountry2V6(string &ret, GeoIPNetmask& gl, const string &ip) override { + GeoIPLookup tmp_gl = { + .netmask = gl.netmask, + }; if (d_db_type == GEOIP_COUNTRY_EDITION_V6 || d_db_type == GEOIP_LARGE_COUNTRY_EDITION_V6) { - ret = GeoIP_code_by_id(GeoIP_id_by_addr_v6_gl(d_gi.get(), ip.c_str(), gl)); + ret = GeoIP_code_by_id(GeoIP_id_by_addr_v6_gl(d_gi.get(), ip.c_str(), &tmp_gl)); + gl.netmask = tmp_gl.netmask; return true; } else if (d_db_type == GEOIP_REGION_EDITION_REV0 || d_db_type == GEOIP_REGION_EDITION_REV1) { - GeoIPRegion* gir = GeoIP_region_by_addr_v6_gl(d_gi.get(), ip.c_str(), gl); + GeoIPRegion* gir = GeoIP_region_by_addr_v6_gl(d_gi.get(), ip.c_str(), &tmp_gl); if (gir) { + gl.netmask = tmp_gl.netmask; ret = GeoIP_code_by_id(GeoIP_id_by_code(gir->country_code)); return true; } @@ -144,22 +164,27 @@ public: GeoIPRecord *gir = GeoIP_record_by_addr_v6(d_gi.get(), ip.c_str()); if (gir) { ret = gir->country_code; - gl->netmask = gir->netmask; + gl.netmask = gir->netmask; return true; } } return false; } - bool queryContinent(string &ret, GeoIPLookup* gl, const string &ip) override { + bool queryContinent(string &ret, GeoIPNetmask& gl, const string &ip) override { + GeoIPLookup tmp_gl = { + .netmask = gl.netmask, + }; if (d_db_type == GEOIP_COUNTRY_EDITION || d_db_type == GEOIP_LARGE_COUNTRY_EDITION) { - ret = GeoIP_continent_by_id(GeoIP_id_by_addr_gl(d_gi.get(), ip.c_str(), gl)); + ret = GeoIP_continent_by_id(GeoIP_id_by_addr_gl(d_gi.get(), ip.c_str(), &tmp_gl)); + gl.netmask = tmp_gl.netmask; return true; } else if (d_db_type == GEOIP_REGION_EDITION_REV0 || d_db_type == GEOIP_REGION_EDITION_REV1) { - GeoIPRegion* gir = GeoIP_region_by_addr_gl(d_gi.get(), ip.c_str(), gl); + GeoIPRegion* gir = GeoIP_region_by_addr_gl(d_gi.get(), ip.c_str(), &tmp_gl); if (gir) { + gl.netmask = tmp_gl.netmask; ret = GeoIP_continent_by_id(GeoIP_id_by_code(gir->country_code)); return true; } @@ -168,22 +193,27 @@ public: GeoIPRecord *gir = GeoIP_record_by_addr(d_gi.get(), ip.c_str()); if (gir) { ret = ret = GeoIP_continent_by_id(GeoIP_id_by_code(gir->country_code)); - gl->netmask = gir->netmask; + gl.netmask = gir->netmask; return true; } } return false; } - bool queryContinentV6(string &ret, GeoIPLookup* gl, const string &ip) override { + bool queryContinentV6(string &ret, GeoIPNetmask& gl, const string &ip) override { + GeoIPLookup tmp_gl = { + .netmask = gl.netmask, + }; if (d_db_type == GEOIP_COUNTRY_EDITION_V6 || d_db_type == GEOIP_LARGE_COUNTRY_EDITION_V6) { - ret = GeoIP_continent_by_id(GeoIP_id_by_addr_v6_gl(d_gi.get(), ip.c_str(), gl)); + ret = GeoIP_continent_by_id(GeoIP_id_by_addr_v6_gl(d_gi.get(), ip.c_str(), &tmp_gl)); + gl.netmask = tmp_gl.netmask; return true; } else if (d_db_type == GEOIP_REGION_EDITION_REV0 || d_db_type == GEOIP_REGION_EDITION_REV1) { - GeoIPRegion* gir = GeoIP_region_by_addr_v6_gl(d_gi.get(), ip.c_str(), gl); + GeoIPRegion* gir = GeoIP_region_by_addr_v6_gl(d_gi.get(), ip.c_str(), &tmp_gl); if (gir) { + gl.netmask = tmp_gl.netmask; ret = GeoIP_continent_by_id(GeoIP_id_by_code(gir->country_code)); return true; } @@ -192,18 +222,22 @@ public: GeoIPRecord *gir = GeoIP_record_by_addr_v6(d_gi.get(), ip.c_str()); if (gir) { ret = GeoIP_continent_by_id(GeoIP_id_by_code(gir->country_code)); - gl->netmask = gir->netmask; + gl.netmask = gir->netmask; return true; } } return false; } - bool queryName(string &ret, GeoIPLookup* gl, const string &ip) override { + bool queryName(string &ret, GeoIPNetmask& gl, const string &ip) override { + GeoIPLookup tmp_gl = { + .netmask = gl.netmask, + }; if (d_db_type == GEOIP_ISP_EDITION || d_db_type == GEOIP_ORG_EDITION) { - string val = valueOrEmpty(GeoIP_name_by_addr_gl(d_gi.get(), ip.c_str(), gl)); + string val = valueOrEmpty(GeoIP_name_by_addr_gl(d_gi.get(), ip.c_str(), &tmp_gl)); if (!val.empty()) { + gl.netmask = tmp_gl.netmask; // reduce space to dash ret = boost::replace_all_copy(val, " ", "-"); return true; @@ -212,11 +246,15 @@ public: return false; } - bool queryNameV6(string &ret, GeoIPLookup* gl, const string &ip) override { + bool queryNameV6(string &ret, GeoIPNetmask& gl, const string &ip) override { + GeoIPLookup tmp_gl = { + .netmask = gl.netmask, + }; if (d_db_type == GEOIP_ISP_EDITION_V6 || d_db_type == GEOIP_ORG_EDITION_V6) { - string val = valueOrEmpty(GeoIP_name_by_addr_v6_gl(d_gi.get(), ip.c_str(), gl)); + string val = valueOrEmpty(GeoIP_name_by_addr_v6_gl(d_gi.get(), ip.c_str(), &tmp_gl)); if (!val.empty()) { + gl.netmask = tmp_gl.netmask; // reduce space to dash ret = boost::replace_all_copy(val, " ", "-"); return true; @@ -225,13 +263,17 @@ public: return false; } - bool queryASnum(string &ret, GeoIPLookup* gl, const string &ip) override { + bool queryASnum(string &ret, GeoIPNetmask& gl, const string &ip) override { + GeoIPLookup tmp_gl = { + .netmask = gl.netmask, + }; if (d_db_type == GEOIP_ASNUM_EDITION) { - string val = valueOrEmpty(GeoIP_name_by_addr_gl(d_gi.get(), ip.c_str(), gl)); + string val = valueOrEmpty(GeoIP_name_by_addr_gl(d_gi.get(), ip.c_str(), &tmp_gl)); if (!val.empty()) { vector asnr; stringtok(asnr, val); if(asnr.size()>0) { + gl.netmask = tmp_gl.netmask; ret = asnr[0]; return true; } @@ -240,13 +282,17 @@ public: return false; } - bool queryASnumV6(string &ret, GeoIPLookup* gl, const string &ip) override { + bool queryASnumV6(string &ret, GeoIPNetmask& gl, const string &ip) override { + GeoIPLookup tmp_gl = { + .netmask = gl.netmask, + }; if (d_db_type == GEOIP_ASNUM_EDITION_V6) { - string val = valueOrEmpty(GeoIP_name_by_addr_v6_gl(d_gi.get(), ip.c_str(), gl)); + string val = valueOrEmpty(GeoIP_name_by_addr_v6_gl(d_gi.get(), ip.c_str(), &tmp_gl)); if (!val.empty()) { vector asnr; stringtok(asnr, val); if(asnr.size()>0) { + gl.netmask = tmp_gl.netmask; ret = asnr[0]; return true; } @@ -255,11 +301,15 @@ public: return false; } - bool queryRegion(string &ret, GeoIPLookup* gl, const string &ip) override { + bool queryRegion(string &ret, GeoIPNetmask& gl, const string &ip) override { + GeoIPLookup tmp_gl = { + .netmask = gl.netmask, + }; if (d_db_type == GEOIP_REGION_EDITION_REV0 || d_db_type == GEOIP_REGION_EDITION_REV1) { - GeoIPRegion *gir = GeoIP_region_by_addr_gl(d_gi.get(), ip.c_str(), gl); + GeoIPRegion *gir = GeoIP_region_by_addr_gl(d_gi.get(), ip.c_str(), &tmp_gl); if (gir) { + gl.netmask = tmp_gl.netmask; ret = valueOrEmpty(gir->region); return true; } @@ -268,18 +318,22 @@ public: GeoIPRecord *gir = GeoIP_record_by_addr(d_gi.get(), ip.c_str()); if (gir) { ret = valueOrEmpty(gir->region); - gl->netmask = gir->netmask; + gl.netmask = gir->netmask; return true; } } return false; } - bool queryRegionV6(string &ret, GeoIPLookup* gl, const string &ip) override { + bool queryRegionV6(string &ret, GeoIPNetmask& gl, const string &ip) override { + GeoIPLookup tmp_gl = { + .netmask = gl.netmask, + }; if (d_db_type == GEOIP_REGION_EDITION_REV0 || d_db_type == GEOIP_REGION_EDITION_REV1) { - GeoIPRegion *gir = GeoIP_region_by_addr_v6_gl(d_gi.get(), ip.c_str(), gl); + GeoIPRegion *gir = GeoIP_region_by_addr_v6_gl(d_gi.get(), ip.c_str(), &tmp_gl); if (gir) { + gl.netmask = tmp_gl.netmask; ret = valueOrEmpty(gir->region); return true; } @@ -288,33 +342,33 @@ public: GeoIPRecord *gir = GeoIP_record_by_addr_v6(d_gi.get(), ip.c_str()); if (gir) { ret = valueOrEmpty(gir->region); - gl->netmask = gir->netmask; + gl.netmask = gir->netmask; return true; } } return false; } - bool queryCity(string &ret, GeoIPLookup* gl, const string &ip) override { + bool queryCity(string &ret, GeoIPNetmask& gl, const string &ip) override { if (d_db_type == GEOIP_CITY_EDITION_REV0 || d_db_type == GEOIP_CITY_EDITION_REV1) { GeoIPRecord *gir = GeoIP_record_by_addr(d_gi.get(), ip.c_str()); if (gir) { ret = valueOrEmpty(gir->city); - gl->netmask = gir->netmask; + gl.netmask = gir->netmask; return true; } } return false; } - bool queryCityV6(string &ret, GeoIPLookup* gl, const string &ip) override { + bool queryCityV6(string &ret, GeoIPNetmask& gl, const string &ip) override { if (d_db_type == GEOIP_CITY_EDITION_REV0_V6 || d_db_type == GEOIP_CITY_EDITION_REV1_V6) { GeoIPRecord *gir = GeoIP_record_by_addr_v6(d_gi.get(), ip.c_str()); if (gir) { ret = valueOrEmpty(gir->city); - gl->netmask = gir->netmask; + gl.netmask = gir->netmask; return true; } } diff --git a/modules/geoipbackend/geoipinterface.hh b/modules/geoipbackend/geoipinterface.hh index c307ad697..20ebb05e8 100644 --- a/modules/geoipbackend/geoipinterface.hh +++ b/modules/geoipbackend/geoipinterface.hh @@ -34,20 +34,20 @@ public: Region }; - virtual bool queryCountry(string &ret, GeoIPLookup* gl, const string &ip) = 0; - virtual bool queryCountryV6(string &ret, GeoIPLookup* gl, const string &ip) = 0; - virtual bool queryCountry2(string &ret, GeoIPLookup* gl, const string &ip) = 0; - virtual bool queryCountry2V6(string &ret, GeoIPLookup* gl, const string &ip) = 0; - virtual bool queryContinent(string &ret, GeoIPLookup* gl, const string &ip) = 0; - virtual bool queryContinentV6(string &ret, GeoIPLookup* gl, const string &ip) = 0; - virtual bool queryName(string &ret, GeoIPLookup* gl, const string &ip) = 0; - virtual bool queryNameV6(string &ret, GeoIPLookup* gl, const string &ip) = 0; - virtual bool queryASnum(string &ret, GeoIPLookup* gl, const string &ip) = 0; - virtual bool queryASnumV6(string &ret, GeoIPLookup* gl, const string &ip) = 0; - virtual bool queryRegion(string &ret, GeoIPLookup* gl, const string &ip) = 0; - virtual bool queryRegionV6(string &ret, GeoIPLookup* gl, const string &ip) = 0; - virtual bool queryCity(string &ret, GeoIPLookup* gl, const string &ip) = 0; - virtual bool queryCityV6(string &ret, GeoIPLookup* gl, const string &ip) = 0; + virtual bool queryCountry(string &ret, GeoIPNetmask& gl, const string &ip) = 0; + virtual bool queryCountryV6(string &ret, GeoIPNetmask& gl, const string &ip) = 0; + virtual bool queryCountry2(string &ret, GeoIPNetmask& gl, const string &ip) = 0; + virtual bool queryCountry2V6(string &ret, GeoIPNetmask& gl, const string &ip) = 0; + virtual bool queryContinent(string &ret, GeoIPNetmask& gl, const string &ip) = 0; + virtual bool queryContinentV6(string &ret, GeoIPNetmask& gl, const string &ip) = 0; + virtual bool queryName(string &ret, GeoIPNetmask& gl, const string &ip) = 0; + virtual bool queryNameV6(string &ret, GeoIPNetmask& gl, const string &ip) = 0; + virtual bool queryASnum(string &ret, GeoIPNetmask& gl, const string &ip) = 0; + virtual bool queryASnumV6(string &ret, GeoIPNetmask& gl, const string &ip) = 0; + virtual bool queryRegion(string &ret, GeoIPNetmask& gl, const string &ip) = 0; + virtual bool queryRegionV6(string &ret, GeoIPNetmask& gl, const string &ip) = 0; + virtual bool queryCity(string &ret, GeoIPNetmask& gl, const string &ip) = 0; + virtual bool queryCityV6(string &ret, GeoIPNetmask& gl, const string &ip) = 0; virtual ~GeoIPInterface() { }