]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Add a parameter to PoolAction to keep processing rules
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 12 Jan 2022 09:07:01 +0000 (10:07 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 12 Jan 2022 09:07:01 +0000 (10:07 +0100)
pdns/dnsdist-lua-actions.cc
pdns/dnsdistdist/docs/rules-actions.rst

index 44b614dfe11291c476845722e42f941d9d5e1928..1ce6cc7500abea3f8204b6a8846272e77e9e6c4d 100644 (file)
@@ -273,12 +273,20 @@ void TeeAction::worker()
 class PoolAction : public DNSAction
 {
 public:
-  PoolAction(const std::string& pool) : d_pool(pool) {}
+  PoolAction(const std::string& pool, bool stopProcessing) : d_pool(pool), d_stopProcessing(stopProcessing) {}
+
   DNSAction::Action operator()(DNSQuestion* dq, std::string* ruleresult) const override
   {
-    *ruleresult=d_pool;
-    return Action::Pool;
+    if (d_stopProcessing) {
+      *ruleresult = d_pool;
+      return Action::Pool;
+    }
+    else {
+      dq->poolname = d_pool;
+      return Action::None;
+    }
   }
+
   std::string toString() const override
   {
     return "to pool "+d_pool;
@@ -286,6 +294,7 @@ public:
 
 private:
   std::string d_pool;
+  bool d_stopProcessing;
 };
 
 
@@ -2141,8 +2150,8 @@ void setupLuaActions(LuaContext& luaCtx)
       return std::shared_ptr<DNSAction>(new SetEDNSOptionAction(code, data));
     });
 
-  luaCtx.writeFunction("PoolAction", [](const std::string& a) {
-      return std::shared_ptr<DNSAction>(new PoolAction(a));
+  luaCtx.writeFunction("PoolAction", [](const std::string& a, boost::optional<bool> stopProcessing) {
+    return std::shared_ptr<DNSAction>(new PoolAction(a, stopProcessing.get_value_or(true)));
     });
 
   luaCtx.writeFunction("QPSAction", [](int limit) {
index 2bcf91ff127bffbd9a97b0e823e5b01639d432e8..592cc47a6b3cc7b65c02a792eab32dc672bd92f5 100644 (file)
@@ -1204,11 +1204,15 @@ The following actions exist.
   Strip RD bit from the question, let it go through.
   Subsequent rules are processed after this action.
 
-.. function:: PoolAction(poolname)
+.. function:: PoolAction(poolname [, stop])
 
-  Send the packet into the specified pool.
+  .. versionchanged:: 1.8.0
+    Added the ``stop`` optional parameter.
+
+  Send the packet into the specified pool. If ``stop`` is set to false, subsequent rules will be processed after this action.
 
   :param string poolname: The name of the pool
+  :param bool stop: Whether to stop processing rules after this action. Default is true, meaning the remaining rules will not be processed.
 
 .. function:: QPSAction(maxqps)