]> granicus.if.org Git - pdns/commitdiff
add crude geoiplookup function
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 15 Mar 2018 14:53:07 +0000 (15:53 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 15 Mar 2018 14:53:07 +0000 (15:53 +0100)
pdns/lua-record.cc

index 28845a9ecf7b5574786b5a8ac750abc6cb84465d..029e7ed3842f95a2a7dc2b8b07cfbff64ecc2c39 100644 (file)
@@ -734,7 +734,11 @@ std::vector<shared_ptr<DNSRecordContent>> luaSynth(const std::string& code, cons
     });
   lua.executeCode("debug.sethook(report, '', 1000)");
 
-  
+  // TODO: make this better. Accept netmask/CA objects; provide names for the attr constants
+  lua.writeFunction("geoiplookup", [](const string &ip, const GeoIPBackend::GeoIPQueryAttribute attr) {
+    return getGeo(ip, attr);
+  });
+
   typedef const boost::variant<string,vector<pair<int,string> > > combovar_t;
   lua.writeFunction("continent", [&bestwho](const combovar_t& continent) {
       string res=getGeo(bestwho.toString(), GeoIPBackend::Continent);