]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Display DynBlocks' default action, None, as the global one 6835/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 8 Aug 2018 15:47:37 +0000 (17:47 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 8 Aug 2018 15:47:37 +0000 (17:47 +0200)
The default action for a dynamic block is Action::None, which doesn't
mean that nothing will be done but that the global action will be
applied instead. We failed to display that correctly in the console
and via the API.

pdns/dnsdist-lua.cc
pdns/dnsdist-web.cc

index 01a6e5f32c558b211bb0f47771e66a083486467a..5309b65bd031b8bfb838a0a182317b85d7eb4d68 100644 (file)
@@ -885,7 +885,7 @@ void setupLuaConfig(bool client)
       g_outputBuffer = (fmt % "What" % "Seconds" % "Blocks" % "Action" % "Reason").str();
       for(const auto& e: slow) {
        if(now < e->second.until)
-         g_outputBuffer+= (fmt % e->first.toString() % (e->second.until.tv_sec - now.tv_sec) % e->second.blocks % DNSAction::typeToString(e->second.action) % e->second.reason).str();
+         g_outputBuffer+= (fmt % e->first.toString() % (e->second.until.tv_sec - now.tv_sec) % e->second.blocks % DNSAction::typeToString(e->second.action != DNSAction::Action::None ? e->second.action : g_dynBlockAction) % e->second.reason).str();
       }
       auto slow2 = g_dynblockSMT.getCopy();
       slow2.visit([&now, &fmt](const SuffixMatchTree<DynBlock>& node) {
@@ -893,7 +893,7 @@ void setupLuaConfig(bool client)
             string dom("empty");
             if(!node.d_value.domain.empty())
               dom = node.d_value.domain.toString();
-            g_outputBuffer+= (fmt % dom % (node.d_value.until.tv_sec - now.tv_sec) % node.d_value.blocks % DNSAction::typeToString(node.d_value.action) % node.d_value.reason).str();
+            g_outputBuffer+= (fmt % dom % (node.d_value.until.tv_sec - now.tv_sec) % node.d_value.blocks % DNSAction::typeToString(node.d_value.action != DNSAction::Action::None ? node.d_value.action : g_dynBlockAction) % node.d_value.reason).str();
           }
         });
 
index b4ea4c1d35d5f06174d73862ef8ff6a990a938da..16ff2ff2eb68c5da22992d10ff83b5d190627a2e 100644 (file)
@@ -333,7 +333,7 @@ static void connectionThread(int sock, ComboAddress remote, string password, str
               {"reason", e->second.reason},
               {"seconds", (double)(e->second.until.tv_sec - now.tv_sec)},
               {"blocks", (double)e->second.blocks},
-              {"action", DNSAction::typeToString(e->second.action) }
+              {"action", DNSAction::typeToString(e->second.action != DNSAction::Action::None ? e->second.action : g_dynBlockAction) }
             };
             obj.insert({e->first.toString(), thing});
           }
@@ -349,7 +349,7 @@ static void connectionThread(int sock, ComboAddress remote, string password, str
                 {"reason", node.d_value.reason},
                 {"seconds", (double)(node.d_value.until.tv_sec - now.tv_sec)},
                 {"blocks", (double)node.d_value.blocks},
-                {"action", DNSAction::typeToString(node.d_value.action) }
+                {"action", DNSAction::typeToString(node.d_value.action != DNSAction::Action::None ? node.d_value.action : g_dynBlockAction) }
               };
               obj.insert({dom, thing});
           }