From f703f7662d62a3cae9c5ffeae75460c481676322 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Tue, 23 Feb 2016 17:18:52 +0100 Subject: [PATCH] add pdns.now timeval struct to recursor lua --- pdns/lua-recursor4.cc | 6 +++++- pdns/syncres.hh | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) 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 -- 2.40.0