]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix formatting issues in dnsdist-lua.cc
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 13 Nov 2023 11:25:48 +0000 (12:25 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 14 Nov 2023 14:43:40 +0000 (15:43 +0100)
pdns/dnsdist-lua.cc

index 6c2d972184a1cd7b0a4682f0e1d438a19b040a0d..f8d3076b0b6851f3294de9313a079fba5d2bf241 100644 (file)
@@ -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<DynBlock> entries;
     auto fullCopy = g_dynblockSMT.getCopy();
     fullCopy.visit([&now, &entries](const SuffixMatchTree<DynBlock>& 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<std::string>& names, const std::string& msg, boost::optional<int> seconds, boost::optional<DNSAction::Action> 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<ComboAddress, std::string>& clientIP, const std::string& msg, const boost::optional<DNSAction::Action> action, const boost::optional<int> seconds, boost::optional<uint8_t> clientIPMask, boost::optional<uint8_t> clientIPPortMask) {
-    setLuaSideEffect();
+                         setLuaSideEffect();
 
-    ComboAddress clientIPCA;
-    if (clientIP.type() == typeid(ComboAddress)) {
-      clientIPCA = boost::get<ComboAddress>(clientIP);
-    }
-    else {
-      auto clientIPStr = boost::get<std::string>(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<ComboAddress>(clientIP);
+                         }
+                         else {
+                           auto clientIPStr = boost::get<std::string>(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;