From: Peter van Dijk Date: Tue, 23 Feb 2016 16:18:52 +0000 (+0100) Subject: add pdns.now timeval struct to recursor lua X-Git-Tag: auth-4.0.0-alpha2~14^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f703f7662d62a3cae9c5ffeae75460c481676322;p=pdns add pdns.now timeval struct to recursor lua --- diff --git a/pdns/lua-recursor4.cc b/pdns/lua-recursor4.cc index b976ad873..ff15943c2 100644 --- a/pdns/lua-recursor4.cc +++ b/pdns/lua-recursor4.cc @@ -318,7 +318,7 @@ RecursorLua4::RecursorLua4(const std::string& fname) theL() << (Logger::Urgency)loglevel << msg< > in_t; - vector > > pd{ + vector > > 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) { diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 5ed097e9e..b5225c460 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -676,5 +676,6 @@ void doCarbonDump(void*); boost::optional getEDNSSubnetMask(const ComboAddress& local, const DNSName&dn, const ComboAddress& rem); void parseEDNSSubnetWhitelist(const std::string& wlist); +extern __thread struct timeval g_now; #endif