diff options
author | special <special@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-04-26 23:46:17 +0000 |
---|---|---|
committer | special <special@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-04-26 23:46:17 +0000 |
commit | 14e03c69169fb16889e528d26ea7b15960fc2744 (patch) | |
tree | aaa36783b879390aad74d42de376bd2d36c9b509 /src | |
parent | 034074d71af6e01d4b663a0566e5668d3d3dad98 (diff) |
Fixed bug #266 (m_dnsbl stats), patch by satmd
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6846 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_dnsbl.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index c2f666c7e..7f4f6ac88 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -33,7 +33,8 @@ class DNSBLConfEntry EnumBanaction banaction; long duration; int bitmask; - DNSBLConfEntry(): duration(86400),bitmask(0) {} + unsigned long stats_hits, stats_misses; + DNSBLConfEntry(): duration(86400),bitmask(0),stats_hits(0), stats_misses(0) {} ~DNSBLConfEntry() { } }; @@ -87,6 +88,7 @@ class DNSBLResolver : public Resolver } ServerInstance->WriteOpers("*** Connecting user %s detected as being on a DNS blacklist (%s) with result %d", them->GetFullRealHost(), ConfEntry->name.c_str(), bitmask); + ConfEntry->stats_hits++; switch (ConfEntry->banaction) { @@ -120,6 +122,8 @@ class DNSBLResolver : public Resolver break; } } + else + ConfEntry->stats_misses++; } } } @@ -172,7 +176,7 @@ class ModuleDNSBL : public Module void Implements(char* List) { - List[I_OnRehash] = List[I_OnUserRegister] = 1; + List[I_OnRehash] = List[I_OnUserRegister] = List[I_OnStats] = 1; } /** Clear entries and free the mem it was using @@ -305,6 +309,28 @@ class ModuleDNSBL : public Module /* don't do anything with this hot potato */ return 0; } + + virtual int OnStats(char symbol, userrec* user, string_list &results) + { + if (symbol != 'd') + return 0; + + unsigned long total_hits = 0, total_misses = 0; + + for (std::vector<DNSBLConfEntry*>::iterator i = DNSBLConfEntries.begin(); i != DNSBLConfEntries.end(); i++) + { + total_hits += (*i)->stats_hits; + total_misses += (*i)->stats_misses; + + results.push_back(std::string(ServerInstance->Config->ServerName) + " 304 " + user->nick + " :DNSBLSTATS DNSbl \"" + (*i)->name + "\" had " + + ConvToStr((*i)->stats_hits) + " hits and " + ConvToStr((*i)->stats_misses) + " misses"); + } + + results.push_back(std::string(ServerInstance->Config->ServerName) + " 304 " + user->nick + " :DNSBLSTATS Total hits: " + ConvToStr(total_hits)); + results.push_back(std::string(ServerInstance->Config->ServerName) + " 304 " + user->nick + " :DNSBLSTATS Total misses: " + ConvToStr(total_misses)); + + return 0; + } }; // stuff down here is the module-factory stuff. |