size_t numberOfQueries = 45 * numberOfSeconds;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < numberOfQueries; idx++) {
g_rings.insertQuery(now, requestor1, qname, qtype, size, dnsHeader, protocol);
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) == nullptr);
}
{
size_t numberOfQueries = (50 * numberOfSeconds) + 1;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < numberOfQueries; idx++) {
g_rings.insertQuery(now, requestor1, qname, qtype, size, dnsHeader, protocol);
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) != nullptr);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor2) == nullptr);
- const auto& block = g_dynblockNMG.getLocal()->lookup(requestor1)->second;
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) != nullptr);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor2) == nullptr);
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1)->second;
BOOST_CHECK_EQUAL(block.reason, reason);
BOOST_CHECK_EQUAL(static_cast<size_t>(block.until.tv_sec), now.tv_sec + blockDuration);
BOOST_CHECK(block.domain.empty());
/* clear the rings and dynamic blocks */
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
/* Insert 100 qps from a given client in the last 10s
this should trigger the rule */
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries * numberOfSeconds);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
/* now we clean up the dynamic blocks, simulating an admin removing the block */
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
/* we apply the rules again, but as if we were 20s in the future.
Since we have a time windows of 10s nothing should be added,
regardless of the number of queries
struct timespec later = now;
later.tv_sec += 20;
dbrg.apply(later);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
/* just in case */
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
/* we apply the rules again, this tile as if we were 5s in the future.
Since we have a time windows of 10s, and 100 qps over 5s then 0 qps over 5s
later = now;
later.tv_sec += 5;
dbrg.apply(later);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
/* clean up */
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
/* we apply the rules again, this tile as if we were 6s in the future.
Since we have a time windows of 10s, and 100 qps over 4s then 0 qps over 6s
later = now;
later.tv_sec += 6;
dbrg.apply(later);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
}
}
size_t numberOfQueries = 45 * numberOfSeconds;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < numberOfQueries; idx++) {
g_rings.insertQuery(now, requestor1, qname, qtype, size, dnsHeader, protocol);
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(AddressAndPortRange(requestor1, 128, 16)) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(AddressAndPortRange(requestor1, 128, 16)) == nullptr);
}
{
size_t numberOfQueries = (50 * numberOfSeconds) + 1;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < numberOfQueries; idx++) {
ComboAddress requestor("2001:db8::" + std::to_string(idx));
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
{
/* beginning of the range should be blocked */
- const auto& block = g_dynblockNMG.getLocal()->lookup(AddressAndPortRange(requestor1, 128, 16))->second;
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(AddressAndPortRange(requestor1, 128, 16))->second;
BOOST_CHECK_EQUAL(block.reason, reason);
BOOST_CHECK_EQUAL(static_cast<size_t>(block.until.tv_sec), now.tv_sec + blockDuration);
BOOST_CHECK(block.domain.empty());
{
/* end of the range should be blocked as well */
ComboAddress end("2001:0db8:0000:0000:ffff:ffff:ffff:ffff");
- const auto& block = g_dynblockNMG.getLocal()->lookup(AddressAndPortRange(end, 128, 16))->second;
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(AddressAndPortRange(end, 128, 16))->second;
BOOST_CHECK_EQUAL(block.reason, reason);
BOOST_CHECK_EQUAL(static_cast<size_t>(block.until.tv_sec), now.tv_sec + blockDuration);
BOOST_CHECK(block.domain.empty());
{
/* outside of the range should NOT */
ComboAddress out("2001:0db8:0000:0001::0");
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(AddressAndPortRange(out, 128, 16)) == nullptr);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(AddressAndPortRange(out, 128, 16)) == nullptr);
}
}
}
size_t numberOfQueries = 45 * numberOfSeconds;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < numberOfQueries; idx++) {
g_rings.insertQuery(now, requestor1, qname, qtype, size, dnsHeader, protocol);
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(AddressAndPortRange(requestor1, 128, 16)) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(AddressAndPortRange(requestor1, 128, 16)) == nullptr);
}
{
size_t numberOfQueries = (50 * numberOfSeconds) + 1;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < numberOfQueries; idx++) {
ComboAddress requestor("192.0.2.1:" + std::to_string(idx));
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
{
/* beginning of the port range should be blocked */
- const auto& block = g_dynblockNMG.getLocal()->lookup(AddressAndPortRange(ComboAddress("192.0.2.1:0"), 32, 16))->second;
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(AddressAndPortRange(ComboAddress("192.0.2.1:0"), 32, 16))->second;
BOOST_CHECK_EQUAL(block.reason, reason);
BOOST_CHECK_EQUAL(static_cast<size_t>(block.until.tv_sec), now.tv_sec + blockDuration);
BOOST_CHECK(block.domain.empty());
{
/* end of the range should be blocked as well */
- const auto& block = g_dynblockNMG.getLocal()->lookup(AddressAndPortRange(ComboAddress("192.0.2.1:16383"), 32, 16))->second;
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(AddressAndPortRange(ComboAddress("192.0.2.1:16383"), 32, 16))->second;
BOOST_CHECK_EQUAL(block.reason, reason);
BOOST_CHECK_EQUAL(static_cast<size_t>(block.until.tv_sec), now.tv_sec + blockDuration);
BOOST_CHECK(block.domain.empty());
{
/* outside of the range should not */
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(AddressAndPortRange(ComboAddress("192.0.2.1:16384"), 32, 16)) == nullptr);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(AddressAndPortRange(ComboAddress("192.0.2.1:16384"), 32, 16)) == nullptr);
}
/* 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 = g_dynblockNMG.getLocal()->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;
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
{
/* previous address/port should still be blocked */
- auto block = g_dynblockNMG.getLocal()->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);
}
/* but not a different one */
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(AddressAndPortRange(ComboAddress("192.0.2.1:16384"), 32, 16)) == nullptr);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(AddressAndPortRange(ComboAddress("192.0.2.1:16384"), 32, 16)) == nullptr);
}
}
size_t numberOfQueries = 45;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t timeIdx = 0; timeIdx < 100; timeIdx++) {
struct timespec when = now;
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries * 100);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) == nullptr);
}
}
size_t numberOfQueries = 45 * numberOfSeconds;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < numberOfQueries; idx++) {
g_rings.insertQuery(now, requestor1, qname, qtype, size, dnsHeader, protocol);
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) == nullptr);
}
{
size_t numberOfQueries = 50 * numberOfSeconds + 1;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < numberOfQueries; idx++) {
g_rings.insertQuery(now, requestor1, qname, QType::A, size, dnsHeader, protocol);
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) == nullptr);
}
{
size_t numberOfQueries = 50 * numberOfSeconds + 1;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < numberOfQueries; idx++) {
g_rings.insertQuery(now, requestor1, qname, qtype, size, dnsHeader, protocol);
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) != nullptr);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor2) == nullptr);
- const auto& block = g_dynblockNMG.getLocal()->lookup(requestor1)->second;
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) != nullptr);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor2) == nullptr);
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1)->second;
BOOST_CHECK_EQUAL(block.reason, reason);
BOOST_CHECK_EQUAL(static_cast<size_t>(block.until.tv_sec), now.tv_sec + blockDuration);
BOOST_CHECK(block.domain.empty());
size_t numberOfResponses = 45 * numberOfSeconds;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
dnsHeader.rcode = rcode;
for (size_t idx = 0; idx < numberOfResponses; idx++) {
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), numberOfResponses);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) == nullptr);
}
{
size_t numberOfResponses = 50 * numberOfSeconds + 1;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
dnsHeader.rcode = RCode::FormErr;
for (size_t idx = 0; idx < numberOfResponses; idx++) {
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), numberOfResponses);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) == nullptr);
}
{
size_t numberOfResponses = 50 * numberOfSeconds + 1;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
dnsHeader.rcode = rcode;
for (size_t idx = 0; idx < numberOfResponses; idx++) {
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), numberOfResponses);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) != nullptr);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor2) == nullptr);
- const auto& block = g_dynblockNMG.getLocal()->lookup(requestor1)->second;
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) != nullptr);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor2) == nullptr);
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1)->second;
BOOST_CHECK_EQUAL(block.reason, reason);
BOOST_CHECK_EQUAL(static_cast<size_t>(block.until.tv_sec), now.tv_sec + blockDuration);
BOOST_CHECK(block.domain.empty());
this should not trigger the rule */
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
dnsHeader.rcode = rcode;
for (size_t idx = 0; idx < 20; idx++) {
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 100U);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) == nullptr);
}
{
/* insert just 50 FormErrs and nothing else, from a given client in the last 10s */
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
dnsHeader.rcode = RCode::FormErr;
for (size_t idx = 0; idx < 50; idx++) {
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 50U);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) == nullptr);
}
{
this should trigger the rule this time */
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
dnsHeader.rcode = rcode;
for (size_t idx = 0; idx < 21; idx++) {
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 100U);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
- BOOST_REQUIRE(g_dynblockNMG.getLocal()->lookup(requestor1) != nullptr);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor2) == nullptr);
- const auto& block = g_dynblockNMG.getLocal()->lookup(requestor1)->second;
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
+ BOOST_REQUIRE(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) != nullptr);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor2) == nullptr);
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1)->second;
BOOST_CHECK_EQUAL(block.reason, reason);
BOOST_CHECK_EQUAL(block.until.tv_sec, now.tv_sec + blockDuration);
BOOST_CHECK(block.domain.empty());
this should NOT trigger the rule since we don't have more than 50 queries */
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
dnsHeader.rcode = rcode;
for (size_t idx = 0; idx < 11; idx++) {
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 50U);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) == nullptr);
}
}
size_t numberOfResponses = 99 * numberOfSeconds;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
dnsHeader.rcode = rcode;
for (size_t idx = 0; idx < numberOfResponses; idx++) {
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), numberOfResponses);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) == nullptr);
}
{
size_t numberOfResponses = 100 * numberOfSeconds + 1;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
dnsHeader.rcode = rcode;
for (size_t idx = 0; idx < numberOfResponses; idx++) {
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), numberOfResponses);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) != nullptr);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor2) == nullptr);
- const auto& block = g_dynblockNMG.getLocal()->lookup(requestor1)->second;
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) != nullptr);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor2) == nullptr);
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1)->second;
BOOST_CHECK_EQUAL(block.reason, reason);
BOOST_CHECK_EQUAL(static_cast<size_t>(block.until.tv_sec), now.tv_sec + blockDuration);
BOOST_CHECK(block.domain.empty());
this should not trigger the rule */
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < 20; idx++) {
g_rings.insertResponse(now, requestor1, qname, qtype, responseTime, size, dnsHeader, backend, outgoingProtocol);
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 100U);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) == nullptr);
}
{
this should trigger the rule this time */
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < 51; idx++) {
g_rings.insertResponse(now, requestor1, qname, qtype, responseTime, size, dnsHeader, backend, outgoingProtocol);
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 100U);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
- BOOST_REQUIRE(g_dynblockNMG.getLocal()->lookup(requestor1) != nullptr);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor2) == nullptr);
- const auto& block = g_dynblockNMG.getLocal()->lookup(requestor1)->second;
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
+ BOOST_REQUIRE(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) != nullptr);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor2) == nullptr);
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1)->second;
BOOST_CHECK_EQUAL(block.reason, reason);
BOOST_CHECK_EQUAL(block.until.tv_sec, now.tv_sec + blockDuration);
BOOST_CHECK(block.domain.empty());
this should NOT trigger the rule since we don't have more than 50 queries */
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < 40; idx++) {
g_rings.insertResponse(now, requestor1, qname, qtype, responseTime, size, dnsHeader, backend, outgoingProtocol);
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 50U);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) == nullptr);
}
/* the global cache-hit rate is too low, should not trigger */
/* insert 51 cache misses and 49 hits from a given client in the last 10s */
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < 51; idx++) {
g_rings.insertResponse(now, requestor1, qname, qtype, responseTime, size, dnsHeader, backend, outgoingProtocol);
BOOST_CHECK_EQUAL(g_rings.getNumberOfResponseEntries(), 100U);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_REQUIRE(g_dynblockNMG.getLocal()->lookup(requestor1) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_REQUIRE(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) == nullptr);
}
}
size_t numberOfQueries = 20 * numberOfSeconds;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < numberOfQueries; idx++) {
g_rings.insertQuery(now, requestor1, qname, qtype, size, dnsHeader, protocol);
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) == nullptr);
}
{
size_t numberOfQueries = 20 * numberOfSeconds + 1;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < numberOfQueries; idx++) {
g_rings.insertQuery(now, requestor1, qname, qtype, size, dnsHeader, protocol);
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) != nullptr);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor2) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) != nullptr);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor2) == nullptr);
{
- const auto& block = g_dynblockNMG.getLocal()->lookup(requestor1)->second;
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1)->second;
BOOST_CHECK_EQUAL(block.reason, reason);
BOOST_CHECK_EQUAL(static_cast<size_t>(block.until.tv_sec), now.tv_sec + blockDuration);
BOOST_CHECK(block.domain.empty());
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) != nullptr);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor2) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) != nullptr);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor2) == nullptr);
{
- const auto& block = g_dynblockNMG.getLocal()->lookup(requestor1)->second;
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1)->second;
BOOST_CHECK_EQUAL(block.reason, reason);
BOOST_CHECK_EQUAL(static_cast<size_t>(block.until.tv_sec), now.tv_sec + blockDuration);
BOOST_CHECK(block.domain.empty());
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) != nullptr);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor2) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) != nullptr);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor2) == nullptr);
{
- const auto& block = g_dynblockNMG.getLocal()->lookup(requestor1)->second;
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1)->second;
BOOST_CHECK_EQUAL(block.reason, reason);
/* should have been updated */
BOOST_CHECK_EQUAL(static_cast<size_t>(block.until.tv_sec), now.tv_sec + blockDuration);
size_t numberOfQueries = 50 * numberOfSeconds + 1;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < numberOfQueries; idx++) {
g_rings.insertQuery(now, requestor1, qname, qtype, size, dnsHeader, protocol);
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) != nullptr);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor2) == nullptr);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) != nullptr);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor2) == nullptr);
{
- const auto& block = g_dynblockNMG.getLocal()->lookup(requestor1)->second;
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1)->second;
BOOST_CHECK_EQUAL(block.reason, reason);
BOOST_CHECK_EQUAL(static_cast<size_t>(block.until.tv_sec), now.tv_sec + blockDuration);
BOOST_CHECK(block.domain.empty());
size_t numberOfQueries = 50 * numberOfSeconds + 1;
g_rings.clear();
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), 0U);
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
for (size_t idx = 0; idx < numberOfQueries; idx++) {
g_rings.insertQuery(now, requestor1, qname, qtype, size, dnsHeader, protocol);
BOOST_CHECK_EQUAL(g_rings.getNumberOfQueryEntries(), numberOfQueries * 2);
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1U);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor1) != nullptr);
- BOOST_CHECK(g_dynblockNMG.getLocal()->lookup(requestor2) == nullptr);
- const auto& block = g_dynblockNMG.getLocal()->lookup(requestor1)->second;
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1U);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1) != nullptr);
+ BOOST_CHECK(dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor2) == nullptr);
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor1)->second;
BOOST_CHECK_EQUAL(block.reason, reason);
BOOST_CHECK_EQUAL(static_cast<size_t>(block.until.tv_sec), now.tv_sec + blockDuration);
BOOST_CHECK(block.domain.empty());
DynBlockRulesGroup dbrg;
dbrg.setQuiet(true);
g_rings.clear();
- g_dynblockNMG.setState(emptyNMG);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
{
/* block above 0 qps for numberOfSeconds seconds, no warning */
/* we apply the rules, all clients should be blocked */
dbrg.apply(now);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 256U);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 256U);
for (size_t idx = 0; idx < 256; idx++) {
const ComboAddress requestor("192.0.2." + std::to_string(idx));
- const auto& block = g_dynblockNMG.getLocal()->lookup(requestor)->second;
+ const auto& block = dnsdist::DynamicBlocks::getClientAddressDynamicRules().lookup(requestor)->second;
/* simulate that:
- .1 does 1 query
...
struct timespec expired = now;
expired.tv_sec += blockDuration + 1;
DynBlockMaintenance::purgeExpired(expired);
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
}
{
DynBlockRulesGroup dbrg;
dbrg.setQuiet(true);
g_rings.clear();
- g_dynblockNMG.setState(emptyNMG);
- g_dynblockSMT.setState(emptySMT);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
+ dnsdist::DynamicBlocks::clearSuffixDynamicRules();
{
DynBlockRulesGroup::DynBlockRule rule(reason, blockDuration, 0, 0, numberOfSeconds, action);
for (size_t idx = 0; idx < 256; idx++) {
const DNSName name(DNSName(std::to_string(idx)) + qname);
- const auto* block = g_dynblockSMT.getLocal()->lookup(name);
+ const auto* block = dnsdist::DynamicBlocks::getSuffixDynamicRules().lookup(name);
BOOST_REQUIRE(block != nullptr);
BOOST_REQUIRE(block->action == action);
/* simulate that:
struct timespec expired = now;
expired.tv_sec += blockDuration + 1;
DynBlockMaintenance::purgeExpired(expired);
- BOOST_CHECK(g_dynblockSMT.getLocal()->getNodes().empty());
+ BOOST_CHECK(dnsdist::DynamicBlocks::getSuffixDynamicRules().getNodes().empty());
}
{
DynBlockRulesGroup dbrg;
dbrg.setQuiet(true);
g_rings.clear();
- g_dynblockNMG.setState(emptyNMG);
- g_dynblockSMT.setState(emptySMT);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
+ dnsdist::DynamicBlocks::clearSuffixDynamicRules();
{
DynBlockRulesGroup::DynBlockRule rule(reason, blockDuration, 0, 0, numberOfSeconds, action);
for (size_t idx = 0; idx < 256; idx++) {
const DNSName name(DNSName(std::to_string(idx)) + qname);
- const auto* block = g_dynblockSMT.getLocal()->lookup(name);
+ const auto* block = dnsdist::DynamicBlocks::getSuffixDynamicRules().lookup(name);
BOOST_REQUIRE(block != nullptr);
BOOST_REQUIRE(block->action == DNSAction::Action::Truncate);
/* simulate that:
struct timespec expired = now;
expired.tv_sec += blockDuration + 1;
DynBlockMaintenance::purgeExpired(expired);
- BOOST_CHECK(g_dynblockSMT.getLocal()->getNodes().empty());
+ BOOST_CHECK(dnsdist::DynamicBlocks::getSuffixDynamicRules().getNodes().empty());
}
#ifdef BENCH_DYNBLOCKS
DynBlockRulesGroup dbrg;
dbrg.setQuiet(true);
g_rings.clear();
- g_dynblockNMG.setState(emptyNMG);
- g_dynblockSMT.setState(emptySMT);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
+ dnsdist::DynamicBlocks::clearSuffixDynamicRules();
{
DynBlockRulesGroup::DynBlockRule rule(reason, blockDuration, 0, 0, numberOfSeconds, action);
sw.start();
DynBlockMaintenance::purgeExpired(expired);
cerr<<"removed 1000000 entries in "<<std::to_string(sw.udiff()/1024)<<"ms"<<endl;
- BOOST_CHECK_EQUAL(g_dynblockSMT.getLocal()->getNodes().size(), 0U);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getSuffixDynamicRules().getNodes().size(), 0U);
}
#endif
DynBlockRulesGroup dbrg;
dbrg.setQuiet(true);
g_rings.clear();
- g_dynblockNMG.setState(emptyNMG);
- g_dynblockSMT.setState(emptySMT);
+ dnsdist::DynamicBlocks::clearClientAddressDynamicRules();
+ dnsdist::DynamicBlocks::clearSuffixDynamicRules();
{
DynBlockRulesGroup::DynBlockRule rule(reason, blockDuration, 0, 0, numberOfSeconds, action);
dbrg.setQueryRate(std::move(rule));
StopWatch sw;
sw.start();
dbrg.apply(now);
- cerr<<"added "<<g_dynblockNMG.getLocal()->size()<<" entries in "<<std::to_string(sw.udiff()/1024)<<"ms"<<endl;
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 1000000U);
+ cerr<<"added "<<dnsdist::DynamicBlocks::getClientAddressDynamicRules().size()<<" entries in "<<std::to_string(sw.udiff()/1024)<<"ms"<<endl;
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 1000000U);
sw.start();
auto top = DynBlockMaintenance::getTopNetmasks(20);
- cerr<<"scanned "<<g_dynblockNMG.getLocal()->size()<<" entries in "<<std::to_string(sw.udiff()/1024)<<"ms"<<endl;
+ cerr<<"scanned "<<dnsdist::DynamicBlocks::getClientAddressDynamicRules().size()<<" entries in "<<std::to_string(sw.udiff()/1024)<<"ms"<<endl;
struct timespec expired = now;
expired.tv_sec += blockDuration + 1;
sw.start();
DynBlockMaintenance::purgeExpired(expired);
cerr<<"removed 1000000 entries in "<<std::to_string(sw.udiff()/1024)<<"ms"<<endl;
- BOOST_CHECK_EQUAL(g_dynblockNMG.getLocal()->size(), 0U);
+ BOOST_CHECK_EQUAL(dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(), 0U);
}
#endif
}