From: Remi Gacogne Date: Mon, 13 Nov 2023 11:25:48 +0000 (+0100) Subject: dnsdist: Fix formatting issues in dnsdist-lua.cc X-Git-Tag: rec-5.0.0-rc1~31^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ae753a08383b7baea7901ac5fcc149ec6fac993;p=thirdparty%2Fpdns.git dnsdist: Fix formatting issues in dnsdist-lua.cc --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 6c2d972184..f8d3076b0b 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -1438,7 +1438,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) entry.action = g_dynBlockAction; } entries.emplace(requestor.toString(), std::move(entry)); - } + } return entries; }); @@ -1450,11 +1450,11 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) LuaAssociativeTable entries; auto fullCopy = g_dynblockSMT.getCopy(); fullCopy.visit([&now, &entries](const SuffixMatchTree& node) { - if (!(now < node.d_value.until)) { + if (!(now < node.d_value.until)) { return; } auto entry = node.d_value; - string key("empty"); + string key("empty"); if (!entry.domain.empty()) { key = entry.domain.toString(); } @@ -1532,62 +1532,62 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) luaCtx.writeFunction("addDynBlockSMT", [](const LuaArray& names, const std::string& msg, boost::optional seconds, boost::optional action) { - if (names.empty()) { - return; - } - setLuaSideEffect(); - struct timespec now; - gettime(&now); - unsigned int actualSeconds = seconds ? *seconds : 10; + if (names.empty()) { + return; + } + setLuaSideEffect(); + struct timespec now; + gettime(&now); + unsigned int actualSeconds = seconds ? *seconds : 10; - bool needUpdate = false; - auto slow = g_dynblockSMT.getCopy(); - for (const auto& capair : names) { - DNSName domain(capair.second); - domain.makeUsLowerCase(); + bool needUpdate = false; + auto slow = g_dynblockSMT.getCopy(); + for (const auto& capair : names) { + DNSName domain(capair.second); + domain.makeUsLowerCase(); - if (dnsdist::DynamicBlocks::addOrRefreshBlockSMT(slow, now, domain, msg, actualSeconds, action ? *action : DNSAction::Action::None, false)) { - needUpdate = true; - } - } + if (dnsdist::DynamicBlocks::addOrRefreshBlockSMT(slow, now, domain, msg, actualSeconds, action ? *action : DNSAction::Action::None, false)) { + needUpdate = true; + } + } - if (needUpdate) { - g_dynblockSMT.setState(slow); - } - }); + if (needUpdate) { + g_dynblockSMT.setState(slow); + } + }); luaCtx.writeFunction("addDynamicBlock", [](const boost::variant& clientIP, const std::string& msg, const boost::optional action, const boost::optional seconds, boost::optional clientIPMask, boost::optional clientIPPortMask) { - setLuaSideEffect(); + setLuaSideEffect(); - ComboAddress clientIPCA; - if (clientIP.type() == typeid(ComboAddress)) { - clientIPCA = boost::get(clientIP); - } - else { - auto clientIPStr = boost::get(clientIP); - try { - clientIPCA = ComboAddress(clientIPStr); - } - catch (const std::exception& exp) { - errlog("addDynamicBlock: Unable to parse '%s': %s", clientIPStr, exp.what()); - return; - } - catch (const PDNSException& exp) { - errlog("addDynamicBlock: Unable to parse '%s': %s", clientIPStr, exp.reason); - return; - } - } - AddressAndPortRange target(clientIPCA, clientIPMask ? *clientIPMask : (clientIPCA.isIPv4() ? 32 : 128), clientIPPortMask ? *clientIPPortMask : 0); - unsigned int actualSeconds = seconds ? *seconds : 10; + ComboAddress clientIPCA; + if (clientIP.type() == typeid(ComboAddress)) { + clientIPCA = boost::get(clientIP); + } + else { + auto clientIPStr = boost::get(clientIP); + try { + clientIPCA = ComboAddress(clientIPStr); + } + catch (const std::exception& exp) { + errlog("addDynamicBlock: Unable to parse '%s': %s", clientIPStr, exp.what()); + return; + } + catch (const PDNSException& exp) { + errlog("addDynamicBlock: Unable to parse '%s': %s", clientIPStr, exp.reason); + return; + } + } + AddressAndPortRange target(clientIPCA, clientIPMask ? *clientIPMask : (clientIPCA.isIPv4() ? 32 : 128), clientIPPortMask ? *clientIPPortMask : 0); + unsigned int actualSeconds = seconds ? *seconds : 10; - struct timespec now; - gettime(&now); - auto slow = g_dynblockNMG.getCopy(); - if (dnsdist::DynamicBlocks::addOrRefreshBlock(slow, now, target, msg, actualSeconds, action ? *action : DNSAction::Action::None, false, false)) { - g_dynblockNMG.setState(slow); - } - }); + struct timespec now; + gettime(&now); + auto slow = g_dynblockNMG.getCopy(); + if (dnsdist::DynamicBlocks::addOrRefreshBlock(slow, now, target, msg, actualSeconds, action ? *action : DNSAction::Action::None, false, false)) { + g_dynblockNMG.setState(slow); + } + }); luaCtx.writeFunction("setDynBlocksPurgeInterval", [](uint64_t interval) { DynBlockMaintenance::s_expiredDynBlocksPurgeInterval = interval;