DynBlockRule(const std::string& blockReason, unsigned int blockDuration, unsigned int rate, unsigned int warningRate, unsigned int seconds, DNSAction::Action action): d_blockReason(blockReason), d_blockDuration(blockDuration), d_rate(rate), d_warningRate(warningRate), d_seconds(seconds), d_action(action), d_enabled(true)
{
- if (d_warningRate > 0) {
- d_warningEnabled = true;
- }
}
bool matches(const struct timespec& when)
bool warningRateExceeded(unsigned int count, const struct timespec& now) const
{
- if (!d_warningEnabled) {
+ if (d_warningRate == 0) {
return false;
}
bool isEnabled() const
{
- return d_enabled || d_warningEnabled;
+ return d_enabled;
}
std::string toString() const
unsigned int d_seconds{0};
DNSAction::Action d_action{DNSAction::Action::None};
bool d_enabled{false};
- bool d_warningEnabled{false};
};
typedef std::unordered_map<ComboAddress, Counts, ComboAddress::addressOnlyHash, ComboAddress::addressOnlyEqual> counts_t;