]> granicus.if.org Git - pdns/commitdiff
add magicLatLon
authorbert hubert <bert.hubert@netherlabs.nl>
Wed, 27 Dec 2017 12:16:30 +0000 (13:16 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Wed, 27 Dec 2017 12:16:30 +0000 (13:16 +0100)
pdns/lua-record.cc

index 6c1258a59e38d40ccca557be012ea9fb33155ff5..4bc65c9ab09524a9c01b7fd434e0b6c1f9f1abb2 100644 (file)
@@ -439,6 +439,14 @@ std::vector<shared_ptr<DNSRecordContent>> luaSynth(const std::string& code, cons
       return closest(bestwho, candidates).toString();
     });
   
+  lua.writeFunction("latlonMagic", [&query](){
+      auto labels= query.getRawLabels();
+      if(labels.size()<4)
+        return std::string("unknown");
+      double lat, lon;
+      getLatLon(labels[3]+"."+labels[2]+"."+labels[1]+"."+labels[0], lat, lon);
+      return std::to_string(lat)+" "+std::to_string(lon);
+    });
 
   
   lua.writeFunction("createReverse", [&bestwho,&query,&zone](string suffix, boost::optional<std::unordered_map<string,string>> e){