From 3fb0ecf2e97aeaed88db090ec593564c7d6f200d Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 20 Dec 2021 13:40:09 +0000 Subject: Refactor the DNSBL config types slightly. --- src/modules/m_dnsbl.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 203b75518..eb5eec78c 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -371,14 +371,15 @@ class DNSBLResolver final } }; -typedef std::vector> DNSBLConfList; +typedef std::vector> DNSBLEntries; class ModuleDNSBL final : public Module , public Stats::EventListener { - DNSBLConfList DNSBLConfEntries; + private: dynamic_reference DNS; + DNSBLEntries dnsbls; StringExtItem nameExt; IntExtItem countExt; @@ -405,14 +406,13 @@ class ModuleDNSBL final void ReadConfig(ConfigStatus& status) override { - DNSBLConfList newentries; + DNSBLEntries newdnsbls; for (const auto& [_, tag] : ServerInstance->Config->ConfTags("dnsbl")) { auto entry = std::make_shared(tag); - newentries.push_back(entry); + newdnsbls.push_back(entry); } - - DNSBLConfEntries.swap(newentries); + dnsbls.swap(newdnsbls); } void OnSetUserIP(LocalUser* user) override @@ -455,16 +455,16 @@ class ModuleDNSBL final ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Reversed IP %s -> %s", user->GetIPString().c_str(), reversedip.c_str()); - countExt.Set(user, DNSBLConfEntries.size()); + countExt.Set(user, dnsbls.size()); // For each DNSBL, we will run through this lookup - for (unsigned i = 0; i < DNSBLConfEntries.size(); ++i) + for (const auto& dnsbl : dnsbls) { // Fill hostname with a dnsbl style host (d.c.b.a.domain.tld) - std::string hostname = reversedip + "." + DNSBLConfEntries[i]->domain; + std::string hostname = reversedip + "." + dnsbl->domain; /* now we'd need to fire off lookups for `hostname'. */ - DNSBLResolver *r = new DNSBLResolver(*this->DNS, this, nameExt, countExt, hostname, user, DNSBLConfEntries[i]); + DNSBLResolver *r = new DNSBLResolver(*this->DNS, this, nameExt, countExt, hostname, user, dnsbl); try { this->DNS->Process(r); @@ -519,14 +519,14 @@ class ModuleDNSBL final unsigned long total_hits = 0; unsigned long total_misses = 0; unsigned long total_errors = 0; - for (const auto& e : DNSBLConfEntries) + for (const auto& dnsbl : dnsbls) { - total_hits += e->stats_hits; - total_misses += e->stats_misses; - total_errors += e->stats_errors; + total_hits += dnsbl->stats_hits; + total_misses += dnsbl->stats_misses; + total_errors += dnsbl->stats_errors; stats.AddRow(304, InspIRCd::Format("DNSBLSTATS \"%s\" had %lu hits, %lu misses, and %lu errors", - e->name.c_str(), e->stats_hits, e->stats_misses, e->stats_errors)); + dnsbl->name.c_str(), dnsbl->stats_hits, dnsbl->stats_misses, dnsbl->stats_errors)); } stats.AddRow(304, "DNSBLSTATS Total hits: " + ConvToStr(total_hits)); -- cgit v1.3.1-10-gc9f91