DNSAction::Action operator()(DNSQuestion* dq, std::string* ruleresult) const override
{
if (d_stopProcessing) {
+ /* we need to do it that way to keep compatiblity with custom Lua actions returning DNSAction.Pool, 'poolname' */
*ruleresult = d_pool;
return Action::Pool;
}
std::string toString() const override
{
- return "to pool "+d_pool;
+ return "to pool " + d_pool;
}
private:
- std::string d_pool;
- bool d_stopProcessing;
+ const std::string d_pool;
+ const bool d_stopProcessing;
};
class QPSPoolAction : public DNSAction
{
public:
- QPSPoolAction(unsigned int limit, const std::string& pool) : d_qps(QPSLimiter(limit, limit)), d_pool(pool) {}
+ QPSPoolAction(unsigned int limit, const std::string& pool, bool stopProcessing) : d_qps(QPSLimiter(limit, limit)), d_pool(pool), d_stopProcessing(stopProcessing) {}
DNSAction::Action operator()(DNSQuestion* dq, std::string* ruleresult) const override
{
if (d_qps.lock()->check()) {
- *ruleresult = d_pool;
- return Action::Pool;
+ if (d_stopProcessing) {
+ /* we need to do it that way to keep compatiblity with custom Lua actions returning DNSAction.Pool, 'poolname' */
+ *ruleresult = d_pool;
+ return Action::Pool;
+ }
+ else {
+ dq->poolname = d_pool;
+ return Action::None;
+ }
}
else {
return Action::None;
}
std::string toString() const override
{
- return "max " +std::to_string(d_qps.lock()->getRate())+" to pool "+d_pool;
+ return "max " + std::to_string(d_qps.lock()->getRate()) + " to pool " + d_pool;
}
private:
mutable LockGuarded<QPSLimiter> d_qps;
const std::string d_pool;
+ const bool d_stopProcessing;
};
class RCodeAction : public DNSAction
});
luaCtx.writeFunction("PoolAction", [](const std::string& a, boost::optional<bool> stopProcessing) {
- return std::shared_ptr<DNSAction>(new PoolAction(a, stopProcessing.get_value_or(true)));
+ return std::shared_ptr<DNSAction>(new PoolAction(a, stopProcessing.get_value_or(true)));
});
luaCtx.writeFunction("QPSAction", [](int limit) {
return std::shared_ptr<DNSAction>(new QPSAction(limit));
});
- luaCtx.writeFunction("QPSPoolAction", [](int limit, const std::string& a) {
- return std::shared_ptr<DNSAction>(new QPSPoolAction(limit, a));
+ luaCtx.writeFunction("QPSPoolAction", [](int limit, const std::string& a, boost::optional<bool> stopProcessing) {
+ return std::shared_ptr<DNSAction>(new QPSPoolAction(limit, a, stopProcessing.get_value_or(true)));
});
luaCtx.writeFunction("SpoofAction", [](boost::variant<std::string,vector<pair<int, std::string>>> inp, boost::optional<responseParams_t> vars) {
.. function:: QPSPoolAction(maxqps, poolname)
- Send the packet into the specified pool only if it does not exceed the ``maxqps`` queries per second limits.
+ .. versionchanged:: 1.8.0
+ Added the ``stop`` optional parameter.
+
+ Send the packet into the specified pool only if it does not exceed the ``maxqps`` queries per second limits. If ``stop`` is set to false, subsequent rules will be processed after this action.
Letting the subsequent rules apply otherwise.
:param int maxqps: The QPS limit for that pool
: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:: RCodeAction(rcode [, options])