dnsdist::QueryCount::Configuration d_queryCountConfig;
std::string d_secPollSuffix{"secpoll.powerdns.com."};
std::string d_apiConfigDirectory;
+ uint64_t d_dynBlocksPurgeInterval{60};
size_t d_maxTCPQueriesPerConn{0};
size_t d_maxTCPConnectionDuration{0};
size_t d_proxyProtocolMaximumSize{512};
std::list<DynBlockMaintenance::MetricsSnapshot> DynBlockMaintenance::s_metricsData;
LockGuarded<DynBlockMaintenance::Tops> DynBlockMaintenance::s_tops;
-size_t DynBlockMaintenance::s_topN{20};
-time_t DynBlockMaintenance::s_expiredDynBlocksPurgeInterval{60};
void DynBlockMaintenance::collectMetrics()
{
static const time_t metricsGenerationInterval = 60;
time_t now = time(nullptr);
- time_t nextExpiredPurge = now + s_expiredDynBlocksPurgeInterval;
+ auto purgeInterval = dnsdist::configuration::getCurrentRuntimeConfiguration().d_dynBlocksPurgeInterval;
+ time_t nextExpiredPurge = now + purgeInterval;
time_t nextMetricsCollect = now + metricsCollectionInterval;
time_t nextMetricsGeneration = now + metricsGenerationInterval;
while (true) {
time_t sleepDelay = std::numeric_limits<time_t>::max();
- if (s_expiredDynBlocksPurgeInterval > 0) {
+ if (purgeInterval > 0) {
sleepDelay = std::min(sleepDelay, (nextExpiredPurge - now));
}
sleepDelay = std::min(sleepDelay, (nextMetricsCollect - now));
nextMetricsGeneration = now + metricsGenerationInterval;
}
- if (s_expiredDynBlocksPurgeInterval > 0 && now >= nextExpiredPurge) {
- struct timespec tspec
- {
- };
+ purgeInterval = dnsdist::configuration::getCurrentRuntimeConfiguration().d_dynBlocksPurgeInterval;
+ if (purgeInterval > 0 && now >= nextExpiredPurge) {
+ timespec tspec{};
gettime(&tspec);
purgeExpired(tspec);
now = time(nullptr);
- nextExpiredPurge = now + s_expiredDynBlocksPurgeInterval;
+ nextExpiredPurge = now + purgeInterval;
}
}
catch (const std::exception& e) {
static std::map<std::string, std::list<std::pair<DNSName, unsigned int>>> getTopSuffixes(size_t topN);
static void purgeExpired(const struct timespec& now);
- static time_t s_expiredDynBlocksPurgeInterval;
-
private:
static void collectMetrics();
static void generateMetrics();
/* s_metricsData should only be accessed by the dynamic blocks maintenance thread so it does not need a lock */
// need N+1 datapoints to be able to do the diff after a collection point has been reached
static std::list<MetricsSnapshot> s_metricsData;
- static size_t s_topN;
+ static constexpr size_t s_topN{20};
};
namespace dnsdist::DynamicBlocks
config.d_payloadSizeSelfGenAnswers = newValue;
},
std::numeric_limits<uint64_t>::max()},
+#ifndef DISABLE_DYNBLOCKS
+ {"setDynBlocksPurgeInterval", [](dnsdist::configuration::RuntimeConfiguration& config, uint64_t newValue) { config.d_dynBlocksPurgeInterval = newValue; }, std::numeric_limits<uint32_t>::max()},
+#endif /* DISABLE_DYNBLOCKS */
};
struct StringConfigurationItems
}
});
#endif /* DISABLE_DEPRECATED_DYNBLOCK */
-
- luaCtx.writeFunction("setDynBlocksPurgeInterval", [](uint64_t interval) {
- DynBlockMaintenance::s_expiredDynBlocksPurgeInterval = static_cast<time_t>(interval);
- });
#endif /* DISABLE_DYNBLOCKS */
#ifdef HAVE_DNSCRYPT