From 693f7ebabe9c227128a0ca7879a9d518c2ae52b8 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 8 Aug 2018 17:47:37 +0200 Subject: [PATCH] dnsdist: Display DynBlocks' default action, None, as the global one 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 | 4 ++-- pdns/dnsdist-web.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 01a6e5f32c..5309b65bd0 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -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& 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(); } }); diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index b4ea4c1d35..16ff2ff2eb 100644 --- a/pdns/dnsdist-web.cc +++ b/pdns/dnsdist-web.cc @@ -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}); } -- 2.47.2