From: Remi Gacogne Date: Tue, 12 Nov 2019 11:19:50 +0000 (+0100) Subject: dnsdist: Lowercase the name blocked by a SMT dynamic block X-Git-Tag: dnsdist-1.4.0~5^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F8524%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Lowercase the name blocked by a SMT dynamic block This does not change the existing behavior since we are doing a case-insensitive comparison but it's nicer when generating metrics about the dynamic block rules. --- diff --git a/pdns/dnsdist-dynblocks.hh b/pdns/dnsdist-dynblocks.hh index 5d9923fb07..d2640e4628 100644 --- a/pdns/dnsdist-dynblocks.hh +++ b/pdns/dnsdist-dynblocks.hh @@ -444,6 +444,7 @@ private: unsigned int count = 0; const auto& got = blocks.lookup(name); bool expired = false; + DNSName domain(name.makeLowerCase()); if (got) { if (until < got->until) { @@ -460,13 +461,13 @@ private: } } - DynBlock db{rule.d_blockReason, until, name, rule.d_action}; + DynBlock db{rule.d_blockReason, until, domain, rule.d_action}; db.blocks = count; if (!d_beQuiet && (!got || expired)) { - warnlog("Inserting dynamic block for %s for %d seconds: %s", name, rule.d_blockDuration, rule.d_blockReason); + warnlog("Inserting dynamic block for %s for %d seconds: %s", domain, rule.d_blockDuration, rule.d_blockReason); } - blocks.add(name, db); + blocks.add(domain, db); updated = true; } diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 39ef2da24d..8908a2f8b9 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -1132,6 +1132,7 @@ void setupLuaConfig(bool client) for(const auto& capair : names) { unsigned int count = 0; DNSName domain(capair.second); + domain.makeUsLowerCase(); auto got = slow.lookup(domain); bool expired=false; if(got) {