]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: add a Lua function to get the config dir and name 15435/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 14 Apr 2025 14:35:27 +0000 (16:35 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 14 Apr 2025 14:35:27 +0000 (16:35 +0200)
pdns/recursordist/docs/lua-scripting/functions.rst
pdns/recursordist/lua-recursor4.cc

index 628ff91805592166556de027dbdda3d1f6adcd24..b2566e0bb0b05efc9d319fb265e798414f4ca033 100644 (file)
@@ -65,3 +65,9 @@ These are some functions that don't really have a place in one of the other cate
    Note that setting both limits to zero can produce very large strings. It is wise to set at least one of the limits.
    Additionally, setting ``maxSize`` to zero can lead to less efficient memory management while producing the dump.
 
+.. function:: getConfigDirAndName() -> str, str
+
+   .. versionadded:: 5.2.3
+
+   Get the configuration directory and the instance name.
+   These two values correspond to the :ref:`setting-yaml-recursor.config_dir` and :ref:`setting-yaml-recursor.config_name` settings.
index b5f83881c5d07f199a1f364f187cd36548a9c0c9..ef834b0f93c972344a4e3ee1ff849084e6ef7adc 100644 (file)
@@ -33,6 +33,7 @@
 #include "filterpo.hh"
 #include "rec-snmp.hh"
 #include "rec-main.hh"
+#include "arguments.hh"
 
 boost::optional<dnsheader> RecursorLua4::DNSQuestion::getDH() const
 {
@@ -515,6 +516,13 @@ void RecursorLua4::postPrepareContext() // NOLINT(readability-function-cognitive
     thread.detach();
   });
 
+  d_lw->writeFunction("getConfigDirAndName", []() -> std::tuple<std::string, std::string> {
+      std::string dir = ::arg()["config-dir"];
+      cleanSlashes(dir);
+      std::string name = ::arg()["config-name"];
+      return {dir, name};
+  });
+
 
   if (!d_include_path.empty()) {
     includePath(d_include_path);