]> granicus.if.org Git - pdns/commitdiff
add pdns.now timeval struct to recursor lua
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 23 Feb 2016 16:18:52 +0000 (17:18 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Wed, 24 Feb 2016 11:35:30 +0000 (12:35 +0100)
pdns/lua-recursor4.cc
pdns/syncres.hh

index b976ad87332de69d5b93d4c64df79dc78520d45e..ff15943c259486f7dee51bf43f4eed2a00ac863f 100644 (file)
@@ -318,7 +318,7 @@ RecursorLua4::RecursorLua4(const std::string& fname)
       theL() << (Logger::Urgency)loglevel << msg<<endl;
     });
   typedef vector<pair<string, int> > in_t;
-  vector<pair<string, boost::variant<int, in_t > > >  pd{
+  vector<pair<string, boost::variant<int, in_t, struct timeval* > > >  pd{
     {"PASS", (int)PolicyDecision::PASS}, {"DROP",  (int)PolicyDecision::DROP},
     {"TRUNCATE", (int)PolicyDecision::TRUNCATE}
   };
@@ -336,6 +336,10 @@ RecursorLua4::RecursorLua4(const std::string& fname)
   
   for(const auto& n : QType::names)
     pd.push_back({n.first, n.second});
+  pd.push_back({"now", &g_now});
+  d_lw->registerMember("tv_sec", &timeval::tv_sec);
+  d_lw->registerMember("tv_usec", &timeval::tv_usec);
+
   d_lw->writeVariable("pdns", pd);
 
   d_lw->writeFunction("getMetric", [](const std::string& str) {
index 5ed097e9ebfecc92ab0782070797da998d332d59..b5225c46062db998572165303e01cfa7aeeb7522 100644 (file)
@@ -676,5 +676,6 @@ void doCarbonDump(void*);
 boost::optional<Netmask> getEDNSSubnetMask(const ComboAddress& local, const DNSName&dn, const ComboAddress& rem);
 void  parseEDNSSubnetWhitelist(const std::string& wlist);
 
+extern __thread struct timeval g_now;
 
 #endif