]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: remove addLuaAction and addLuaResponseAction 7670/head
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 4 Apr 2019 14:44:22 +0000 (16:44 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 4 Apr 2019 14:44:22 +0000 (16:44 +0200)
pdns/dnsdist-console.cc
pdns/dnsdist-lua-actions.cc
pdns/dnsdistdist/docs/advanced/luaaction.rst
pdns/dnsdistdist/docs/advanced/timedipsetrule.rst
pdns/dnsdistdist/docs/reference/constants.rst
pdns/dnsdistdist/docs/rules-actions.rst
pdns/dnsdistdist/docs/upgrade_guide.rst
regression-tests.dnsdist/test_EDNSOptions.py
regression-tests.dnsdist/test_EDNSSelfGenerated.py
regression-tests.dnsdist/test_Trailing.py

index 87e6b10ef985ff6e19e957cb7473d35652cd732a..6ed2244b8399f4a3272f004e9546ee55806c8008 100644 (file)
@@ -347,8 +347,6 @@ const std::vector<ConsoleKeyword> g_consoleKeywords{
   { "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 [, {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" },
   { "addSelfAnsweredResponseAction", true, "DNS rule, DNS response action [, {uuid=\"UUID\"}]", "add a self-answered response rule" },
index 55c7251e0aaca0866ec83c78e1ffc17cdf89c5bf..faecc8b7195487ad7b64fcb37e37ce1dd724edbe 100644 (file)
@@ -1053,14 +1053,6 @@ void setupLuaActions()
       addAction(&g_rulactions, var, boost::get<std::shared_ptr<DNSAction> >(era), params);
     });
 
-  g_lua.writeFunction("addLuaAction", [](luadnsrule_t var, LuaAction::func_t func, boost::optional<luaruleparams_t> params) {
-      addAction(&g_rulactions, var, std::make_shared<LuaAction>(func), params);
-    });
-
-  g_lua.writeFunction("addLuaResponseAction", [](luadnsrule_t var, LuaResponseAction::func_t func, boost::optional<luaruleparams_t> params) {
-      addAction(&g_resprulactions, var, std::make_shared<LuaResponseAction>(func), params);
-    });
-
   g_lua.writeFunction("addResponseAction", [](luadnsrule_t var, boost::variant<std::shared_ptr<DNSAction>, std::shared_ptr<DNSResponseAction> > era, boost::optional<luaruleparams_t> params) {
       if (era.type() != typeid(std::shared_ptr<DNSResponseAction>)) {
         throw std::runtime_error("addResponseAction() can only be called with response-related actions, not query-related ones. Are you looking for addAction()?");
index 89be18efce60ba1054ec66b7b42667ba334656e8..0655f513e34433731e1f2aac9d854affc7cc12f7 100644 (file)
@@ -4,7 +4,7 @@ Lua actions in rules
 While we can pass every packet through the :func:`blockFilter` functions, it is also possible to configure :program:`dnsdist` to only hand off some packets for Lua inspection. 
 If you think Lua is too slow for your query load, or if you are doing heavy processing in Lua, this may make sense.
 
-To select specific packets for Lua attention, use :func:`addLuaAction` or :func:`addLuaResponseAction`.
+To select specific packets for Lua attention, use :func:`addAction` with :func:`LuaAction`, or :func:`addResponseAction` with :func:`LuaResponseAction`.
 
 A sample configuration could look like this::
 
@@ -17,4 +17,4 @@ A sample configuration could look like this::
     end
   end
 
-  addLuaAction(AllRule(), luarule)
+  addAction(AllRule(), LuaAction(luarule))
index 5b645405d61a9e43d89e83f15a7675bf0b27bba8..ffdbacf6667b55ff02b1b159e66f3e4eac85aab1 100644 (file)
@@ -63,4 +63,4 @@ A working example:
           end
   end
 
-  addLuaAction(AllRule(), pickPool)
+  addAction(AllRule(), LuaAction(pickPool))
index 407fd1bf91ebcbc5e3805e61104454c15b63071b..248f67148ec1160cf79d618b4b3a7a0e64e63ed9 100644 (file)
@@ -93,7 +93,7 @@ DNS Section
 DNSAction
 ---------
 
-These constants represent an Action that can be returned from the functions invoked by :func:`addLuaAction`.
+These constants represent an Action that can be returned from :func:`LuaAction` functions.
 
  * ``DNSAction.Allow``: let the query pass, skipping other rules
  * ``DNSAction.Delay``: delay the response for the specified milliseconds (UDP-only), continue to the next rule
@@ -115,7 +115,7 @@ These constants represent an Action that can be returned from the functions invo
 DNSResponseAction
 -----------------
 
-These constants represent an Action that can be returned from the functions invoked by :func:`addLuaResponseAction`.
+These constants represent an Action that can be returned from :func:`LuaResponseAction` functions.
 
  * ``DNSResponseAction.Allow``: let the response pass, skipping other rules
  * ``DNSResponseAction.Delay``: delay the response for the specified milliseconds (UDP-only), continue to the next rule
index 36d8b3a55b5702f60250d3f157c1136dcd9e2c42..08dd25511ace10c3ddf6138894345d0610408ac1 100644 (file)
@@ -151,6 +151,9 @@ Rule Generators
   .. versionchanged:: 1.3.0
     The second argument returned by the ``function`` can be omitted. For earlier releases, simply return an empty string.
 
+  .. deprecated:: 1.4.0
+    Removed in 1.4.0, use :func:`LuaAction` with :func:`addAction` instead.
+
   Invoke a Lua function that accepts a :class:`DNSQuestion`.
   This function works similar to using :func:`LuaAction`.
   The ``function`` should return both a :ref:`DNSAction` and its argument `rule`. The `rule` is used as an argument
@@ -187,6 +190,9 @@ Rule Generators
   .. versionchanged:: 1.3.0
     The second argument returned by the ``function`` can be omitted. For earlier releases, simply return an empty string.
 
+  .. deprecated:: 1.4.0
+    Removed in 1.4.0, use :func:`LuaResponseAction` with :func:`addResponseAction` instead.
+
   Invoke a Lua function that accepts a :class:`DNSResponse`.
   This function works similar to using :func:`LuaResponseAction`.
   The ``function`` should return both a :ref:`DNSResponseAction` and its argument `rule`. The `rule` is used as an argument
index 920df10922323ce03e1084b5cca271bb09ca6954..756c08249b587346d9bad99fd3ff66dec11ce82c 100644 (file)
@@ -1,6 +1,11 @@
 Upgrade Guide
 =============
 
+1.3.x to 1.4.0
+--------------
+
+:func:`addLuaAction` and :func:`addLuaResponseAction` have been removed. Instead, use :func:`addAction` with a :func:`LuaAction`, or :func:`addResponseAction` with a :func:`LuaResponseAction`.
+
 1.3.2 to 1.3.3
 --------------
 
index f5838bf40ce1efc50a58ff6352dcd06f7c76b372..dac2058026a42e9dcf9fd2cf96d3d325e5acd0a7 100644 (file)
@@ -66,7 +66,7 @@ class TestEDNSOptions(EDNSOptionsBase):
     _config_template = """
     %s
 
-    addLuaAction(AllRule(), testEDNSOptions)
+    addAction(AllRule(), LuaAction(testEDNSOptions))
 
     newServer{address="127.0.0.1:%s"}
     """
@@ -253,7 +253,7 @@ class TestEDNSOptionsAddingECS(EDNSOptionsBase):
     _config_template = """
     %s
 
-    addLuaAction(AllRule(), testEDNSOptions)
+    addAction(AllRule(), LuaAction(testEDNSOptions))
 
     newServer{address="127.0.0.1:%s", useClientSubnet=true}
     """
index 7704641319a7e08531bb775f5896d105b50dd05b..b4455ffa3290da073bb535fb6628a6c825fbfc07 100644 (file)
@@ -18,7 +18,7 @@ class TestEDNSSelfGenerated(DNSDistTest):
       return DNSAction.Nxdomain, ""
     end
 
-    addLuaAction("lua.edns-self.tests.powerdns.com.", luarule)
+    addAction("lua.edns-self.tests.powerdns.com.", LuaAction(luarule))
 
     addAction("spoof.edns-self.tests.powerdns.com.", SpoofAction({'192.0.2.1', '192.0.2.2'}))
 
@@ -309,7 +309,7 @@ class TestEDNSSelfGeneratedDisabled(DNSDistTest):
       return DNSAction.Nxdomain, ""
     end
 
-    addLuaAction("lua.edns-self-disabled.tests.powerdns.com.", luarule)
+    addAction("lua.edns-self-disabled.tests.powerdns.com.", LuaAction(luarule))
 
     addAction("spoof.edns-self-disabled.tests.powerdns.com.", SpoofAction({'192.0.2.1', '192.0.2.2'}))
 
index a9c74b58556bdeaf7f3e38eb9048f33c031e3ee7..aeb49c9c6d7992a9f93fd1fcc47f3e92b5504dad 100644 (file)
@@ -20,7 +20,7 @@ class TestTrailingDataToBackend(DNSDistTest):
         end
         return DNSAction.None, ""
     end
-    addLuaAction("added.trailing.tests.powerdns.com.", replaceTrailingData)
+    addAction("added.trailing.tests.powerdns.com.", LuaAction(replaceTrailingData))
 
     function fillBuffer(dq)
         local available = dq.size - dq.len
@@ -31,7 +31,7 @@ class TestTrailingDataToBackend(DNSDistTest):
         end
         return DNSAction.None, ""
     end
-    addLuaAction("max.trailing.tests.powerdns.com.", fillBuffer)
+    addAction("max.trailing.tests.powerdns.com.", LuaAction(fillBuffer))
 
     function exceedBuffer(dq)
         local available = dq.size - dq.len
@@ -42,7 +42,7 @@ class TestTrailingDataToBackend(DNSDistTest):
         end
         return DNSAction.None, ""
     end
-    addLuaAction("limited.trailing.tests.powerdns.com.", exceedBuffer)
+    addAction("limited.trailing.tests.powerdns.com.", LuaAction(exceedBuffer))
     """
     @classmethod
     def startResponders(cls):
@@ -183,13 +183,13 @@ class TestTrailingDataToDnsdist(DNSDistTest):
         end
         return DNSAction.None, ""
     end
-    addLuaAction("removed.trailing.tests.powerdns.com.", removeTrailingData)
+    addAction("removed.trailing.tests.powerdns.com.", LuaAction(removeTrailingData))
 
     function reportTrailingData(dq)
         local tail = dq:getTrailingData()
         return DNSAction.Spoof, "-" .. tail .. ".echoed.trailing.tests.powerdns.com."
     end
-    addLuaAction("echoed.trailing.tests.powerdns.com.", reportTrailingData)
+    addAction("echoed.trailing.tests.powerdns.com.", LuaAction(reportTrailingData))
 
     function replaceTrailingData(dq)
         local success = dq:setTrailingData("ABC")
@@ -198,8 +198,8 @@ class TestTrailingDataToDnsdist(DNSDistTest):
         end
         return DNSAction.None, ""
     end
-    addLuaAction("replaced.trailing.tests.powerdns.com.", replaceTrailingData)
-    addLuaAction("replaced.trailing.tests.powerdns.com.", reportTrailingData)
+    addAction("replaced.trailing.tests.powerdns.com.", LuaAction(replaceTrailingData))
+    addAction("replaced.trailing.tests.powerdns.com.", LuaAction(reportTrailingData))
 
     function reportTrailingHex(dq)
         local tail = dq:getTrailingData()
@@ -208,7 +208,7 @@ class TestTrailingDataToDnsdist(DNSDistTest):
         end)
         return DNSAction.Spoof, "-0x" .. hex .. ".echoed-hex.trailing.tests.powerdns.com."
     end
-    addLuaAction("echoed-hex.trailing.tests.powerdns.com.", reportTrailingHex)
+    addAction("echoed-hex.trailing.tests.powerdns.com.", LuaAction(reportTrailingHex))
 
     function replaceTrailingData_unsafe(dq)
         local success = dq:setTrailingData("\\xB0\\x00\\xDE\\xADB\\xF0\\x9F\\x91\\xBB\\xC3\\xBE")
@@ -217,8 +217,8 @@ class TestTrailingDataToDnsdist(DNSDistTest):
         end
         return DNSAction.None, ""
     end
-    addLuaAction("replaced-unsafe.trailing.tests.powerdns.com.", replaceTrailingData_unsafe)
-    addLuaAction("replaced-unsafe.trailing.tests.powerdns.com.", reportTrailingHex)
+    addAction("replaced-unsafe.trailing.tests.powerdns.com.", LuaAction(replaceTrailingData_unsafe))
+    addAction("replaced-unsafe.trailing.tests.powerdns.com.", LuaAction(reportTrailingHex))
     """
 
     def testTrailingDropped(self):