{ "addDNSCryptBind", true, "\"127.0.0.1:8443\", \"provider name\", \"/path/to/resolver.cert\", \"/path/to/resolver.key\", {reusePort=false, tcpFastOpenSize=0, interface=\"\", cpus={}}", "listen to incoming DNSCrypt queries on 127.0.0.1 port 8443, with a provider name of `provider name`, using a resolver certificate and associated key stored respectively in the `resolver.cert` and `resolver.key` files. The fifth optional parameter is a table of parameters" },
{ "addDynBlocks", true, "addresses, message[, seconds[, action]]", "block the set of addresses with message `msg`, for `seconds` seconds (10 by default), applying `action` (default to the one set with `setDynBlocksAction()`)" },
{ "addLocal", true, "addr [, {doTCP=true, reusePort=false, tcpFastOpenSize=0, interface=\"\", cpus={}}]", "add `addr` to the list of addresses we listen on" },
- { "addLuaAction", true, "x, func", "where 'x' is all the combinations from `addAction`, and func is a function with the parameter `dq`, which returns an action to be taken on this packet. Good for rare packets but where you want to do a lot of processing" },
- { "addLuaResponseAction", true, "x, func", "where 'x' is all the combinations from `addAction`, and func is a function with the parameter `dr`, which returns an action to be taken on this response packet. Good for rare packets but where you want to do a lot of processing" },
+ { "addLuaAction", true, "x, func [, {uuid=\"UUID\"}]", "where 'x' is all the combinations from `addAction`, and func is a function with the parameter `dq`, which returns an action to be taken on this packet. Good for rare packets but where you want to do a lot of processing" },
+ { "addLuaResponseAction", true, "x, func [, {uuid=\"UUID\"}]", "where 'x' is all the combinations from `addAction`, and func is a function with the parameter `dr`, which returns an action to be taken on this response packet. Good for rare packets but where you want to do a lot of processing" },
{ "addCacheHitResponseAction", true, "DNS rule, DNS response action [, {uuid=\"UUID\"}]", "add a cache hit response rule" },
{ "addResponseAction", true, "DNS rule, DNS response action [, {uuid=\"UUID\"}]", "add a response rule" },
{ "addTLSLocal", true, "addr, certFile, keyFile[,params]", "listen to incoming DNS over TLS queries on the specified address using the specified certificate and key. The last parameter is a table" },
});
});
- g_lua.writeFunction("addLuaAction", [](luadnsrule_t var, LuaAction::func_t func) {
+ g_lua.writeFunction("addLuaAction", [](luadnsrule_t var, LuaAction::func_t func, boost::optional<luaruleparams_t> params) {
setLuaSideEffect();
+
+ boost::uuids::uuid uuid;
+ parseRuleParams(params, uuid);
+
auto rule=makeRule(var);
- g_rulactions.modify([rule,func](decltype(g_rulactions)::value_type& rulactions){
- rulactions.push_back({
- rule,
- std::make_shared<LuaAction>(func),
- t_uuidGenerator() });
+ g_rulactions.modify([rule, func, uuid](decltype(g_rulactions)::value_type& rulactions){
+ rulactions.push_back({rule, std::make_shared<LuaAction>(func), uuid});
});
});
- g_lua.writeFunction("addLuaResponseAction", [](luadnsrule_t var, LuaResponseAction::func_t func) {
+ g_lua.writeFunction("addLuaResponseAction", [](luadnsrule_t var, LuaResponseAction::func_t func, boost::optional<luaruleparams_t> params) {
setLuaSideEffect();
+
+ boost::uuids::uuid uuid;
+ parseRuleParams(params, uuid);
+
auto rule=makeRule(var);
- g_resprulactions.modify([rule,func](decltype(g_resprulactions)::value_type& rulactions){
- rulactions.push_back({
- rule,
- std::make_shared<LuaResponseAction>(func),
- t_uuidGenerator() });
+ g_resprulactions.modify([rule, func, uuid](decltype(g_resprulactions)::value_type& rulactions){
+ rulactions.push_back({rule, std::make_shared<LuaResponseAction>(func), uuid});
});
});
:param string domain: Domain name to spoof for
:param string cname: Domain name to add CNAME to
-.. function:: addLuaAction(DNSrule, function)
+.. function:: addLuaAction(DNSrule, function [, options])
+
+ .. versionchanged:: 1.3.0
+ Added the optional parameter ``options``.
Invoke a Lua function that accepts a :class:`DNSQuestion`.
This function works similar to using :func:`LuaAction`.
-
The ``function`` should return a :ref:`DNSAction`.
:param DNSRule: match queries based on this rule
:param string function: the name of a Lua function
+ :param table options: A table with key: value pairs with options.
+
+ Options:
+
+ * ``uuid``: string - UUID to assign to the new rule. By default a random UUID is generated for each rule.
-.. function:: addLuaResponseAction(DNSrule, function)
+.. function:: addLuaResponseAction(DNSrule, function [, options])
+
+ .. versionchanged:: 1.3.0
+ Added the optional parameter ``options``.
Invoke a Lua function that accepts a :class:`DNSQuestion` on the response.
This function works similar to using :func:`LuaAction`.
:param DNSRule: match queries based on this rule
:param string function: the name of a Lua function
+ :param table options: A table with key: value pairs with options.
+
+ Options:
+
+ * ``uuid``: string - UUID to assign to the new rule. By default a random UUID is generated for each rule.
.. function:: addNoRecurseRule(DNSrule)