From: Otto Moerbeek Date: Mon, 14 Apr 2025 14:35:27 +0000 (+0200) Subject: rec: add a Lua function to get the config dir and name X-Git-Tag: dnsdist-2.0.0-alpha2~48^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2cf70298c17ace48a112023f68cab2e385240a1a;p=thirdparty%2Fpdns.git rec: add a Lua function to get the config dir and name --- diff --git a/pdns/recursordist/docs/lua-scripting/functions.rst b/pdns/recursordist/docs/lua-scripting/functions.rst index 628ff91805..b2566e0bb0 100644 --- a/pdns/recursordist/docs/lua-scripting/functions.rst +++ b/pdns/recursordist/docs/lua-scripting/functions.rst @@ -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. diff --git a/pdns/recursordist/lua-recursor4.cc b/pdns/recursordist/lua-recursor4.cc index b5f83881c5..ef834b0f93 100644 --- a/pdns/recursordist/lua-recursor4.cc +++ b/pdns/recursordist/lua-recursor4.cc @@ -33,6 +33,7 @@ #include "filterpo.hh" #include "rec-snmp.hh" #include "rec-main.hh" +#include "arguments.hh" boost::optional 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 dir = ::arg()["config-dir"]; + cleanSlashes(dir); + std::string name = ::arg()["config-name"]; + return {dir, name}; + }); + if (!d_include_path.empty()) { includePath(d_include_path);