Amount of time (in seconds) a pre-computed hash entry will be considered as expired when unused. See :func:`pickchashed()`.
+.. _setting-lua-global-include-dir:
+
+``lua-global-include-dir``
+---------------------------
+
+- String
+- Default: empty
+- Example: ``/etc/pdns/lua-global/``
+
+When creating a Lua context, scan this directory for additional lua files. All files that end with
+.lua are loaded in order using ``POSIX`` as locale with Lua scripts.
+
.. _setting-lua-health-checks-expire-delay:
``lua-health-checks-expire-delay``
public:
Lua2BackendAPIv2(const string& suffix)
{
+ d_include_path = ::arg()["lua-global-include-dir"];
setArgPrefix("lua2" + suffix);
d_debug_log = mustDo("query-logging");
prepareContext();
::arg().set("lua-prequery-script", "Lua script with prequery handler (DO NOT USE)") = "";
::arg().set("lua-dnsupdate-policy-script", "Lua script with DNS update policy handler") = "";
+ ::arg().set("lua-global-include-dir", "Include *.lua files from this directory into Lua contexts") = "";
::arg().setSwitch("traceback-handler", "Enable the traceback handler (Linux only)") = "yes";
::arg().setSwitch("direct-dnskey", "Fetch DNSKEY, CDS and CDNSKEY RRs from backend during DNSKEY or CDS/CDNSKEY synthesis") = "no";
unique_ptr<AuthLua4> pdl{nullptr};
vector<string> scripts;
- string script = ::arg()["lua-axfr-script"];
- if (B.getDomainMetadata(domain, "LUA-AXFR-SCRIPT", scripts) && !scripts.empty()) {
+ string script= ::arg()["lua-axfr-script"];
+ if(B.getDomainMetadata(domain, "LUA-AXFR-SCRIPT", scripts) && !scripts.empty()) {
if (pdns_iequals(scripts[0], "NONE")) {
script.clear();
}
}
if (!script.empty()) {
try {
- pdl = make_unique<AuthLua4>();
+ pdl = make_unique<AuthLua4>(::arg()["lua-global-include-dir"]);
pdl->loadFile(script);
g_log << Logger::Info << logPrefix << "loaded Lua script '" << script << "'" << endl;
}
{
if(!LUA || // we don't have a Lua state yet
!g_LuaRecordSharedState) { // or we want a new one even if we had one
- LUA = make_unique<AuthLua4>();
+ LUA = make_unique<AuthLua4>(::arg()["lua-global-include-dir"]);
setupLuaRecords(*LUA->getLua());
}
d_doExpandALIAS = ::arg().mustDo("expand-alias");
d_logDNSDetails= ::arg().mustDo("log-dns-details");
string fname= ::arg()["lua-prequery-script"];
+
if(fname.empty())
{
d_pdl = nullptr;
}
else
{
- d_pdl = std::make_unique<AuthLua4>();
- d_pdl->loadFile(fname); // XXX exception handling?
+ d_pdl = std::make_unique<AuthLua4>(::arg()["lua-global-include-dir"]);
+ d_pdl->loadFile(fname);
}
fname = ::arg()["lua-dnsupdate-policy-script"];
if (fname.empty())
}
else
{
- d_update_policy_lua = std::make_unique<AuthLua4>();
try {
+ d_update_policy_lua = std::make_unique<AuthLua4>();
d_update_policy_lua->loadFile(fname);
}
- catch (const std::runtime_error&) {
+ catch (const std::runtime_error& e) {
+ g_log<<Logger::Warning<<"Failed to load update policy - disabling: "<<e.what()<<endl;
d_update_policy_lua = nullptr;
}
}
'doc' : '''
If set, and Lua support is compiled in, this will load an additional configuration file for newer features and more complicated setups.
See :doc:`lua-config/index` for the options that can be set in this file.
+ ''',
+ },
+ {
+ 'name' : 'lua_global_include_dir',
+ 'section' : 'recursor',
+ 'type' : LType.String,
+ 'default' : '',
+ 'help' : 'More powerful configuration options',
+ 'doc' : '''
+ When creating a Lua context, all *.lua files in the directory are loaded to the Lua context.
''',
},
{