From: bert hubert Date: Sun, 10 Dec 2017 13:12:39 +0000 (+0100) Subject: make geobackend optional, but function with it, even when loaded as a .so X-Git-Tag: dnsdist-1.3.1~136^2~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=924341d2df8a4fecd9815322acbf2d95d2284b7e;p=thirdparty%2Fpdns.git make geobackend optional, but function with it, even when loaded as a .so --- diff --git a/modules/geoipbackend/geoipbackend.cc b/modules/geoipbackend/geoipbackend.cc index ab299da01e..1fdb36de21 100644 --- a/modules/geoipbackend/geoipbackend.cc +++ b/modules/geoipbackend/geoipbackend.cc @@ -87,6 +87,27 @@ GeoIPBackend::GeoIPBackend(const string& suffix) { s_rc++; } +string getGeoForLua(const std::string& ip, GeoIPBackend::GeoIPQueryAttribute qa) +{ + try { + GeoIPBackend gib; + GeoIPLookup gl; + string res=gib.queryGeoIP(ip, false, qa, &gl); + // cout<<"Result for "< tmp_domains; @@ -289,6 +310,9 @@ void GeoIPBackend::initialize() { s_domains.clear(); std::swap(s_domains, tmp_domains); + + extern std::function g_getGeo; + g_getGeo = getGeoForLua; } GeoIPBackend::~GeoIPBackend() { @@ -1098,25 +1122,6 @@ bool GeoIPBackend::hasDNSSECkey(const DNSName& name) { return false; } -string getGeo(const std::string& ip, GeoIPBackend::GeoIPQueryAttribute qa) -{ - try { - GeoIPBackend gib; - GeoIPLookup gl; - string res=gib.queryGeoIP(ip, false, qa, &gl); - // cout<<"Result for "< d_result; }; -std::string getGeo(const std::string& ip, GeoIPBackend::GeoIPQueryAttribute qa); - #endif /* PDNS_GEOIPBACKEND_HH */ diff --git a/pdns/lua-record.cc b/pdns/lua-record.cc index f7fff7d107..8a6db6d7d8 100644 --- a/pdns/lua-record.cc +++ b/pdns/lua-record.cc @@ -6,6 +6,7 @@ #include "minicurl.hh" #include "ueberbackend.hh" #include +// this is only for the ENUM #include "../../modules/geoipbackend/geoipbackend.hh" /* to do: @@ -193,12 +194,20 @@ bool doCompare(const T& var, const std::string& res, const C& cmp) } -std::string getGeo(const std::string& ip, GeoIPBackend::GeoIPQueryAttribute qa) __attribute__((weak)); +std::function g_getGeo; std::string getGeo(const std::string& ip, GeoIPBackend::GeoIPQueryAttribute qa) { - cerr<<"Weak variant called"<& ips)