From: Remi Gacogne Date: Tue, 14 Feb 2023 11:40:05 +0000 (+0100) Subject: Merge pull request #12537 from rgacogne/ddist-faster-maxqpsiprule X-Git-Tag: dnsdist-1.8.0-rc1~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba2cd6c9ec0996bb3634fce2be5fc25847960494;p=thirdparty%2Fpdns.git Merge pull request #12537 from rgacogne/ddist-faster-maxqpsiprule dnsdist: Improve the scalability of MaxQPSIPRule() --- ba2cd6c9ec0996bb3634fce2be5fc25847960494 diff --cc pdns/dnsdist-lua-rules.cc index 7aa16c855f,12a6e4a849..4a8eeb4467 --- a/pdns/dnsdist-lua-rules.cc +++ b/pdns/dnsdist-lua-rules.cc @@@ -383,11 -383,11 +383,11 @@@ void setupLuaRules(LuaContext& luaCtx luaCtx.writeFunction("topSelfAnsweredResponseRules", [](boost::optional top, boost::optional vars) { setLuaNoSideEffect(); auto rules = g_selfansweredrespruleactions.getLocal(); - return rulesToString(getTopRules(*rules, top.get_value_or(10)), vars); + return rulesToString(getTopRules(*rules, (top ? *top : 10)), vars); }); - luaCtx.writeFunction("MaxQPSIPRule", [](unsigned int qps, boost::optional ipv4trunc, boost::optional ipv6trunc, boost::optional burst, boost::optional expiration, boost::optional cleanupDelay, boost::optional scanFraction) { - return std::shared_ptr(new MaxQPSIPRule(qps, burst.get_value_or(qps), ipv4trunc.get_value_or(32), ipv6trunc.get_value_or(64), expiration.get_value_or(300), cleanupDelay.get_value_or(60), scanFraction.get_value_or(10))); + luaCtx.writeFunction("MaxQPSIPRule", [](unsigned int qps, boost::optional ipv4trunc, boost::optional ipv6trunc, boost::optional burst, boost::optional expiration, boost::optional cleanupDelay, boost::optional scanFraction, boost::optional shards) { + return std::shared_ptr(new MaxQPSIPRule(qps, (burst ? *burst : qps), (ipv4trunc ? *ipv4trunc : 32), (ipv6trunc ? *ipv6trunc : 64), (expiration ? *expiration : 300), (cleanupDelay ? *cleanupDelay : 60), (scanFraction ? *scanFraction : 10), (shards ? *shards : 10))); }); luaCtx.writeFunction("MaxQPSRule", [](unsigned int qps, boost::optional burst) {