diff options
author | attilamolnar <attilamolnar@hush.com> | 2012-10-01 00:52:01 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-04-10 19:27:24 +0200 |
commit | a0fdf5fcd51c18e9fa3be245349582e70b69f74f (patch) | |
tree | 8320d6912fddbde5758ef5e6ae9931aa4ba403b4 | |
parent | 239a3bb0f86d2bb431e7d450c992ad7edfd584d7 (diff) |
BanCache: Remove BanCacheHit::IP field, and BanCacheManager::RemoveHit()
The IP field was only used in RemoveHit(), RemoveHit() was only called from GetHit()
-rw-r--r-- | include/bancache.h | 8 | ||||
-rw-r--r-- | src/bancache.cpp | 28 |
2 files changed, 5 insertions, 31 deletions
diff --git a/include/bancache.h b/include/bancache.h index 9f7402336..e975bb68a 100644 --- a/include/bancache.h +++ b/include/bancache.h @@ -37,15 +37,12 @@ class CoreExport BanCacheHit /** Reason, shown as quit message */ std::string Reason; - /** IP to match against, no wildcards here (of course) - */ - std::string IP; /** Time that the ban expires at */ time_t Expiry; - BanCacheHit(const std::string &ip, const std::string &type, const std::string &reason, time_t seconds) - : Type(type), Reason(reason), IP(ip), Expiry(ServerInstance->Time() + seconds) + BanCacheHit(const std::string &type, const std::string &reason, time_t seconds) + : Type(type), Reason(reason), Expiry(ServerInstance->Time() + seconds) { } }; @@ -71,7 +68,6 @@ class CoreExport BanCacheManager */ BanCacheHit *AddHit(const std::string &ip, const std::string &type, const std::string &reason, time_t seconds = 0); BanCacheHit *GetHit(const std::string &ip); - bool RemoveHit(BanCacheHit *b); /** Removes all entries of a given type, either positive or negative. Returns the number of hits removed. * @param type The type of bancache entries to remove (e.g. 'G') diff --git a/src/bancache.cpp b/src/bancache.cpp index a797335d1..c38a31b4d 100644 --- a/src/bancache.cpp +++ b/src/bancache.cpp @@ -44,7 +44,8 @@ BanCacheHit *BanCacheManager::GetHit(const std::string &ip) if (ServerInstance->Time() > i->second->Expiry) { ServerInstance->Logs->Log("BANCACHE", DEBUG, "Hit on " + ip + " is out of date, removing!"); - RemoveHit(i->second); + delete i->second; + BanHash->erase(i); return NULL; // out of date } @@ -52,29 +53,6 @@ BanCacheHit *BanCacheManager::GetHit(const std::string &ip) } } -bool BanCacheManager::RemoveHit(BanCacheHit *b) -{ - BanCacheHash::iterator i; - - if (!b) - return false; // I don't think so. - - i = this->BanHash->find(b->IP); - - if (i == this->BanHash->end()) - { - // err.. - ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCacheManager::RemoveHit(): I got asked to remove a hit that wasn't in the hash(?)"); - } - else - { - this->BanHash->erase(i); - } - - delete b; - return true; -} - unsigned int BanCacheManager::RemoveEntries(const std::string &type, bool positive) { int removed = 0; @@ -99,7 +77,7 @@ unsigned int BanCacheManager::RemoveEntries(const std::string &type, bool positi if ((positive && !b->Reason.empty()) || b->Reason.empty()) { /* we need to remove this one. */ - ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCacheManager::RemoveEntries(): Removing a hit on " + b->IP); + ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCacheManager::RemoveEntries(): Removing a hit on " + n->first); delete b; BanHash->erase(n); // WORD TO THE WISE: don't use RemoveHit here, because we MUST remove the iterator in a safe way. removed++; |