]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add stuct timeval queryTime to dq Lua object.
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 6 Sep 2022 14:27:07 +0000 (16:27 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 6 Sep 2022 14:27:07 +0000 (16:27 +0200)
This is the time the query was received. Value is the same as would be set in
the protobuf message, so protobuf-use-kernel-timestamp is relevant.

pdns/lua-recursor4.cc
pdns/lua-recursor4.hh
pdns/pdns_recursor.cc

index 1c8cbcb8a02552f3387bad18d35a5a5bee2ec427..c0ecc8570d6430ec9877ce87ec45f12573832158 100644 (file)
@@ -205,6 +205,7 @@ void RecursorLua4::postPrepareContext()
   d_lw->registerMember("udpQueryDest", &DNSQuestion::udpQueryDest);
   d_lw->registerMember("udpCallback", &DNSQuestion::udpCallback);
   d_lw->registerMember("appliedPolicy", &DNSQuestion::appliedPolicy);
+  d_lw->registerMember("queryTime", &DNSQuestion::queryTime);
 
   d_lw->registerMember<DNSFilterEngine::Policy, std::string>("policyName",
     [](const DNSFilterEngine::Policy& pol) -> std::string {
index 2fabcc06c3889146afe00a95fad1feffd420770f..d0a476b9e0a845592d7ab1192c79398ab522a289 100644 (file)
@@ -112,6 +112,7 @@ public:
     bool& addPaddingToResponse;
     unsigned int tag{0};
     std::map<std::string, MetaValue> meta;
+    struct timeval queryTime;
 
     void addAnswer(uint16_t type, const std::string& content, boost::optional<int> ttl, boost::optional<string> name);
     void addRecord(uint16_t type, const std::string& content, DNSResourceRecord::Place place, boost::optional<int> ttl, boost::optional<string> name);
index 4469695996db39ad1c129a98946352d2e8c6c38e..7eecb655fec235d87afd82063daf5bec0745dea5 100644 (file)
@@ -997,6 +997,12 @@ void startDoResolve(void* p)
     dq.extendedErrorExtra = &dc->d_extendedErrorExtra;
     dq.meta = std::move(dc->d_meta);
     dq.fromAuthIP = &sr.d_fromAuthIP;
+    if (g_useKernelTimestamp && dc->d_kernelTimestamp.tv_sec != 0) {
+      dq.queryTime = dc->d_kernelTimestamp;
+    }
+    else {
+      dq.queryTime = dc->d_now;
+    }
 
     sr.d_slog = sr.d_slog->withValues("qname", Logging::Loggable(dc->d_mdp.d_qname),
                                       "qtype", Logging::Loggable(QType(dc->d_mdp.d_qtype)),