From: Remi Gacogne Date: Wed, 12 Jan 2022 09:07:01 +0000 (+0100) Subject: dnsdist: Add a parameter to PoolAction to keep processing rules X-Git-Tag: auth-4.7.0-alpha1~30^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=192e413c1ef22558577eb85b0ab201a9dc3f706a;p=thirdparty%2Fpdns.git dnsdist: Add a parameter to PoolAction to keep processing rules --- diff --git a/pdns/dnsdist-lua-actions.cc b/pdns/dnsdist-lua-actions.cc index 44b614dfe1..1ce6cc7500 100644 --- a/pdns/dnsdist-lua-actions.cc +++ b/pdns/dnsdist-lua-actions.cc @@ -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(new SetEDNSOptionAction(code, data)); }); - luaCtx.writeFunction("PoolAction", [](const std::string& a) { - return std::shared_ptr(new PoolAction(a)); + luaCtx.writeFunction("PoolAction", [](const std::string& a, boost::optional stopProcessing) { + return std::shared_ptr(new PoolAction(a, stopProcessing.get_value_or(true))); }); luaCtx.writeFunction("QPSAction", [](int limit) { diff --git a/pdns/dnsdistdist/docs/rules-actions.rst b/pdns/dnsdistdist/docs/rules-actions.rst index 2bcf91ff12..592cc47a6b 100644 --- a/pdns/dnsdistdist/docs/rules-actions.rst +++ b/pdns/dnsdistdist/docs/rules-actions.rst @@ -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)