]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Add missing QPSAction 5686/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 13 Sep 2017 09:33:19 +0000 (11:33 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 13 Sep 2017 09:33:19 +0000 (11:33 +0200)
In 1.2.0 we deprecated the `addQPSLimit()` function, suggesting the
use of `QPSAction()` as a replacement, but the Lua binding for
`QPSAction()` was missing. In addition the documenration was referring
to `QPSLimitAction()` instead of `QPSAction()`.

pdns/dnsdist-lua.cc
pdns/dnsdistdist/docs/rules-actions.rst
regression-tests.dnsdist/test_Advanced.py

index 799c10eb1acb114a78370b23066c2751298bed08..9308cc55e552cabb1c166b1559b11f136cfc3312 100644 (file)
@@ -788,6 +788,10 @@ vector<std::function<void(void)>> setupLua(bool client, const std::string& confi
       return std::shared_ptr<DNSAction>(new PoolAction(a));
     });
 
+  g_lua.writeFunction("QPSAction", [](int limit) {
+      return std::shared_ptr<DNSAction>(new QPSAction(limit));
+    });
+
   g_lua.writeFunction("QPSPoolAction", [](int limit, const string& a) {
       return std::shared_ptr<DNSAction>(new QPSPoolAction(limit, a));
     });
index 1e32776dace29a85b5f887becacd8090038d38fb..873570ef0e166a3c504760c6dffd88c6c79b81bf 100644 (file)
@@ -198,7 +198,7 @@ Rule Generators
   All queries over the limit are dropped.
   This function is deprecated as of 1.2.0 and will be removed in 1.3.0, please use:
 
-    addAction(DNSRule, QPSLimitAction(limit))
+    addAction(DNSRule, QPSAction(limit))
 
   :param DNSRule: match queries based on this rule
   :param int limit: QPS limit for this rule
@@ -222,9 +222,9 @@ Managing Rules
 
 Active Rules can be shown with :func:`showRules` and removed with :func:`rmRule`::
 
-  > addAction("h4xorbooter.xyz.", QPSLimitAction(10))
-  > addAction({"130.161.0.0/16", "145.14.0.0/16"} , QPSLimitAction(20))
-  > addAction({"nl.", "be."}, QPSLimitAction(1))
+  > addAction("h4xorbooter.xyz.", QPSAction(10))
+  > addAction({"130.161.0.0/16", "145.14.0.0/16"} , QPSAction(20))
+  > addAction({"nl.", "be."}, QPSAction(1))
   > showRules()
   #     Matches Rule                                               Action
   0           0 h4xorbooter.xyz.                                   qps limit to 10
@@ -659,6 +659,13 @@ The following actions exist.
 
   :param string poolname: The name of the pool
 
+.. function:: QPSAction(maxqps)
+
+  Drop a packet if it does exceed the ``maxqps`` queries per second limits.
+  Letting the subsequent rules apply otherwise.
+
+  :param int maxqps: The QPS limit
+
 .. function:: QPSPoolAction(maxqps, poolname)
 
   Send the packet into the specified pool only if it does not exceed the ``maxqps`` queries per second limits.
index 7864d8d3c01768ee8f0769b941b57afcecde7c5a..9fbb1b87702ad634ccf0cfa33ac71b8764484b9f 100644 (file)
@@ -921,7 +921,7 @@ class TestAdvancedRestoreFlagsOnSelfResponse(DNSDistTest):
 class TestAdvancedQPS(DNSDistTest):
 
     _config_template = """
-    addQPSLimit("qps.advanced.tests.powerdns.com", 10)
+    addAction("qps.advanced.tests.powerdns.com", QPSAction(10))
     newServer{address="127.0.0.1:%s"}
     """
 
@@ -969,7 +969,7 @@ class TestAdvancedQPS(DNSDistTest):
 class TestAdvancedQPSNone(DNSDistTest):
 
     _config_template = """
-    addQPSLimit("qpsnone.advanced.tests.powerdns.com", 100)
+    addAction("qpsnone.advanced.tests.powerdns.com", QPSAction(100))
     addAction(AllRule(), RCodeAction(dnsdist.REFUSED))
     newServer{address="127.0.0.1:%s"}
     """