1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 /* $Core: libIRCDbancache */
19 BanCacheHit *BanCacheManager::AddHit(const std::string &ip, const std::string &type, const std::string &reason)
24 if (this->BanHash->find(ip) != this->BanHash->end()) // can't have two cache entries on the same IP, sorry..
27 b = new BanCacheHit(ServerInstance, ip, type, reason);
29 this->BanHash->insert(std::make_pair(ip, b));
33 BanCacheHit *BanCacheManager::GetHit(const std::string &ip)
35 BanCacheHash::iterator i = this->BanHash->find(ip);
37 if (i == this->BanHash->end())
38 return NULL; // free and safe
40 return i->second; // hit.
43 bool BanCacheManager::RemoveHit(BanCacheHit *b)
45 BanCacheHash::iterator i;
48 return false; // I don't think so.
50 i = this->BanHash->find(b->IP);
52 if (i == this->BanHash->end())
55 ServerInstance->Log(DEBUG, "BanCacheManager::RemoveHit(): I got asked to remove a hit that wasn't in the hash(?)");
59 this->BanHash->erase(i);
66 void BanCacheManager::RehashCache()
68 BanCacheHash* NewHash = new BanCacheHash();
70 BanCacheHash::iterator safei;
71 for (BanCacheHash::iterator n = BanHash->begin(); n != BanHash->end(); )
76 /* Safe to delete items here through iterator 'n' */
78 /* Actually inserts a std::pair */
81 /* End of safe section */