*/
#pragma once
+#ifndef DISABLE_DYNBLOCKS
#include <unordered_set>
#include "dolog.hh"
static std::list<MetricsSnapshot> s_metricsData;
static size_t s_topN;
};
+
+#endif /* DISABLE_DYNBLOCKS */
}
#endif /* DISABLE_TOP_N_BINDINGS */
+#ifndef DISABLE_DYNBLOCKS
#ifndef DISABLE_DEPRECATED_DYNBLOCK
typedef std::unordered_map<ComboAddress, unsigned int, ComboAddress::addressOnlyHash, ComboAddress::addressOnlyEqual> counts_t;
}
#endif /* DISABLE_DEPRECATED_DYNBLOCK */
+#endif /* DISABLE_DYNBLOCKS */
void setupLuaInspection(LuaContext& luaCtx)
{
}
});
+#ifndef DISABLE_DYNBLOCKS
#ifndef DISABLE_DEPRECATED_DYNBLOCK
luaCtx.writeFunction("exceedServFails", [](unsigned int rate, int seconds) {
setLuaNoSideEffect();
});
luaCtx.registerFunction("setQuiet", &DynBlockRulesGroup::setQuiet);
luaCtx.registerFunction("toString", &DynBlockRulesGroup::toString);
+#endif /* DISABLE_DYNBLOCKS */
}
luaCtx.writeFunction("setECSOverride", [](bool override) { g_ECSOverride = override; });
+#ifndef DISABLE_DYNBLOCKS
luaCtx.writeFunction("showDynBlocks", []() {
setLuaNoSideEffect();
auto slow = g_dynblockNMG.getCopy();
luaCtx.writeFunction("setDynBlocksPurgeInterval", [](uint64_t interval) {
DynBlockMaintenance::s_expiredDynBlocksPurgeInterval = interval;
});
+#endif /* DISABLE_DYNBLOCKS */
#ifdef HAVE_DNSCRYPT
luaCtx.writeFunction("addDNSCryptBind", [](const std::string& addr, const std::string& providerName, LuaTypeOrArrayOf<std::string> certFiles, LuaTypeOrArrayOf<std::string> keyFiles, boost::optional<localbind_t> vars) {
}
});
+#ifndef DISABLE_DYNBLOCKS
#ifndef DISABLE_DEPRECATED_DYNBLOCK
luaCtx.writeFunction("addBPFFilterDynBlocks", [](const std::unordered_map<ComboAddress, unsigned int, ComboAddress::addressOnlyHash, ComboAddress::addressOnlyEqual>& m, std::shared_ptr<DynBPFFilter> dynbpf, boost::optional<int> seconds, boost::optional<std::string> msg) {
if (!dynbpf) {
}
});
#endif /* DISABLE_DEPRECATED_DYNBLOCK */
+#endif /* DISABLE_DYNBLOCKS */
#endif /* HAVE_EBPF */
addRulesToPrometheusOutput(output, g_cachehitrespruleactions);
addRulesToPrometheusOutput(output, g_selfansweredrespruleactions);
+#ifndef DISABLE_DYNBLOCKS
output << "# HELP dnsdist_dynblocks_nmg_top_offenders_hits_per_second " << "Number of hits per second blocked by Dynamic Blocks (netmasks) for the top offenders, averaged over the last 60s" << "\n";
output << "# TYPE dnsdist_dynblocks_nmg_top_offenders_hits_per_second " << "gauge" << "\n";
auto topNetmasksByReason = DynBlockMaintenance::getHitsForTopNetmasks();
output << "dnsdist_dynblocks_smt_top_offenders_hits_per_second{reason=\"" << entry.first << "\",suffix=\"" << suffix.first.toString() << "\"} " << suffix.second << "\n";
}
}
+#endif /* DISABLE_DYNBLOCKS */
output << "# HELP dnsdist_info " << "Info from dnsdist, value is always 1" << "\n";
output << "# TYPE dnsdist_info " << "gauge" << "\n";
}
else if (command == "dynblocklist") {
Json::object obj;
+#ifndef DISABLE_DYNBLOCKS
auto nmg = g_dynblockNMG.getLocal();
struct timespec now;
gettime(&now);
obj.insert({dom, thing});
}
});
-
+#endif /* DISABLE_DYNBLOCKS */
Json my_json = obj;
resp.body = my_json.dump();
resp.headers["Content-Type"] = "application/json";
}
}
+#ifndef DISABLE_DYNBLOCKS
/* the Dynamic Block mechanism supports address and port ranges, so we need to pass the full address and port */
if (auto got = holders.dynNMGBlock->lookup(AddressAndPortRange(*dq.remote, dq.remote->isIPv4() ? 32 : 128, 16))) {
auto updateBlockStats = [&got]() {
}
}
}
+#endif /* DISABLE_DYNBLOCKS */
DNSAction::Action action=DNSAction::Action::None;
string ruleresult;
}
}
+#ifndef DISABLE_DYNBLOCKS
static void dynBlockMaintenanceThread()
{
setThreadName("dnsdist/dynBloc");
DynBlockMaintenance::run();
}
+#endif
#ifndef DISABLE_SECPOLL
static void secPollThread()
thread healththread(healthChecksThread);
+#ifndef DISABLE_DYNBLOCKS
thread dynBlockMaintThread(dynBlockMaintenanceThread);
dynBlockMaintThread.detach();
+#endif /* DISABLE_DYNBLOCKS */
#ifndef DISABLE_SECPOLL
if (!g_secPollSuffix.empty()) {
GlobalStateHolder<SuffixMatchTree<DynBlock>> g_dynblockSMT;
DNSAction::Action g_dynBlockAction = DNSAction::Action::Drop;
+#ifndef DISABLE_DYNBLOCKS
+
void DynBlockRulesGroup::apply(const struct timespec& now)
{
counts_t counts;
{
return s_tops.lock()->topSMTsByReason;
}
+#endif /* DISABLE_DYNBLOCKS */
#include "dnsdist.hh"
#include "dnsdist-dynblocks.hh"
+#ifndef DISABLE_DYNBLOCKS
uint64_t dnsdist_ffi_stat_node_get_queries_count(const dnsdist_ffi_stat_node_t* node)
{
return node->self.queries;
{
node->reason = std::string(reason, reasonSize);
}
+#endif /* DISABLE_DYNBLOCKS */
Rings g_rings;
shared_ptr<BPFFilter> g_defaultBPFFilter{nullptr};
+#ifndef DISABLE_DYNBLOCKS
+
BOOST_AUTO_TEST_SUITE(dnsdistdynblocks_hh)
BOOST_AUTO_TEST_CASE(test_DynBlockRulesGroup_QueryRate) {
}
BOOST_AUTO_TEST_SUITE_END()
+#endif /* DISABLE_DYNBLOCKS */