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 * ---------------------------------------------------
19 class CoreExport BanCacheHit : public classbase
22 InspIRCd *ServerInstance;
28 BanCacheHit(InspIRCd *Instance, const std::string &ip, const std::string &type, const std::string &reason)
30 ServerInstance = Instance;
32 this->Reason = reason;
37 // must be defined after class BanCacheHit.
39 typedef nspace::hash_map<std::string, BanCacheHit *, nspace::hash<std::string> > BanCacheHash;
41 typedef nspace::hash_map<std::string, BanCacheHit*, nspace::hash_compare<string, less<string> > > BanCacheHash;
44 class CoreExport BanCacheManager : public classbase
47 BanCacheHash *BanHash;
48 InspIRCd *ServerInstance;
51 /** Creates and adds a Ban Cache item.
52 * @param ip The IP the item is for.
53 * @param type The type of ban cache item. std::string. .empty() means it's a negative match (user is allowed freely).
54 * @param reason The reason for the ban. Left .empty() if it's a negative match.
56 BanCacheHit *AddHit(const std::string &ip, const std::string &type, const std::string &reason);
57 BanCacheHit *GetHit(const std::string &ip);
58 bool RemoveHit(BanCacheHit *b);
60 /** Removes all entries of a given type, either positive or negative. Returns the number of hits removed.
61 * @param type The type of bancache entries to remove (e.g. 'G')
62 * @param positive Remove either positive (true) or negative (false) hits.
64 int RemoveEntries(const std::string &type, bool positive);
66 BanCacheManager(InspIRCd *Instance)
68 this->ServerInstance = Instance;
69 this->BanHash = new BanCacheHash();