return true;
}
-static void carbonHandler(Carbon::Endpoint endpoint)
+static void carbonHandler(const Carbon::Endpoint& endpoint)
{
setThreadName("dnsdist/carbon");
const auto intervalUSec = endpoint.interval * 1000 * 1000;
void Carbon::run(const std::vector<Carbon::Endpoint>& endpoints)
{
- for (auto& endpoint : endpoints) {
+ for (const auto& endpoint : endpoints) {
std::thread newHandler(carbonHandler, endpoint);
newHandler.detach();
}
}
if (totalWeight > 0) {
- targetLoad = (currentLoad / totalWeight) * consistentHashBalancingFactor;
+ targetLoad = (currentLoad / static_cast<double>(totalWeight)) * consistentHashBalancingFactor;
}
}
}
const auto& pools = dnsdist::configuration::getCurrentRuntimeConfiguration().d_pools;
- auto it = pools.find(poolName);
- if (it == pools.end()) {
+ auto poolIt = pools.find(poolName);
+ if (poolIt == pools.end()) {
return 0;
}
- auto pool = it->second;
+ auto pool = poolIt->second;
if (!pool->packetCache) {
return 0;
}
}
const auto& pools = dnsdist::configuration::getCurrentRuntimeConfiguration().d_pools;
- auto it = pools.find(poolName);
- if (it == pools.end()) {
+ auto poolIt = pools.find(poolName);
+ if (poolIt == pools.end()) {
return 0;
}
- auto pool = it->second;
+ auto pool = poolIt->second;
if (!pool->packetCache) {
return 0;
}
}
else if (auto* str = boost::get<std::string>(&var)) {
const auto uuid = getUniqueID(*str);
- for (auto& state : dnsdist::configuration::getCurrentRuntimeConfiguration().d_backends) {
+ for (const auto& state : dnsdist::configuration::getCurrentRuntimeConfiguration().d_backends) {
if (*state->d_config.id == uuid) {
server = state;
}
auto backends = dnsdist::configuration::getCurrentRuntimeConfiguration().d_backends;
s_servers.clear();
s_servers.reserve(backends.size());
- for (const auto& server : backends) {
+ for (auto& server : backends) {
s_servers.push_back(std::move(server));
}
SSetsockopt(socket, IPPROTO_TCP, TCP_FASTOPEN, clientState.fastOpenQueueSize);
#ifdef TCP_FASTOPEN_KEY
if (!immutableConfig.d_tcpFastOpenKey.empty()) {
- auto res = setsockopt(socket, IPPROTO_IP, TCP_FASTOPEN_KEY, immutableConfig.d_tcpFastOpenKey.data(), immutableConfig.d_tcpFastOpenKey.size() * sizeof(immutableConfig.d_tcpFastOpenKey.at(0)));
+ auto res = setsockopt(socket, IPPROTO_IP, TCP_FASTOPEN_KEY, immutableConfig.d_tcpFastOpenKey.data(), immutableConfig.d_tcpFastOpenKey.size() * sizeof(immutableConfig.d_tcpFastOpenKey[0]));
if (res == -1) {
throw runtime_error("setsockopt for level IPPROTO_TCP and opname TCP_FASTOPEN_KEY failed: " + stringerror());
}
/* we (again) insert just above 50 qps from several clients the same IPv4 port range, this should update the block which will
check by looking at the blocked counter */
{
- auto block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(AddressAndPortRange(ComboAddress("192.0.2.1:0"), 32, 16));
+ auto* block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(AddressAndPortRange(ComboAddress("192.0.2.1:0"), 32, 16));
BOOST_REQUIRE(block != nullptr);
BOOST_CHECK_EQUAL(block->second.blocks, 0U);
block->second.blocks = 42U;
BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
{
/* previous address/port should still be blocked */
- auto block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(AddressAndPortRange(ComboAddress("192.0.2.1:0"), 32, 16));
+ auto* block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(AddressAndPortRange(ComboAddress("192.0.2.1:0"), 32, 16));
BOOST_REQUIRE(block != nullptr);
BOOST_CHECK_EQUAL(block->second.blocks, 42U);
}
)foo";
resetLuaContext();
g_lua.lock()->writeFunction("setServerPolicyLua", [](const string& name, const ServerPolicy::policyfunc_t& policy) {
- auto pol = std::make_shared<ServerPolicy>(name, std::move(policy), true);
+ auto pol = std::make_shared<ServerPolicy>(name, policy, true);
dnsdist::configuration::updateRuntimeConfiguration([&pol](dnsdist::configuration::RuntimeConfiguration& config) {
config.d_lbPolicy = std::move(pol);
});