summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-01-16 21:43:03 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-01-16 21:43:03 +0000
commit4b122677df0f5a501ff8ec89d90903d35310ca23 (patch)
tree6a2a81672a8045d3972eecd1809e94c8ae8a1d72
parentf50ae8b4ca1a43d0bcafcfeb889b315c18708f7e (diff)
Add an overridden AddHit to BanCacheManager, allowing the expiry time to be set.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8723 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/bancache.h3
-rw-r--r--src/bancache.cpp13
2 files changed, 16 insertions, 0 deletions
diff --git a/include/bancache.h b/include/bancache.h
index d69306d7a..5ce8193b6 100644
--- a/include/bancache.h
+++ b/include/bancache.h
@@ -66,6 +66,9 @@ class CoreExport BanCacheManager : public classbase
* @param reason The reason for the ban. Left .empty() if it's a negative match.
*/
BanCacheHit *AddHit(const std::string &ip, const std::string &type, const std::string &reason);
+
+ // Overridden to allow an optional number of seconds before expiry
+ BanCacheHit *AddHit(const std::string &ip, const std::string &type, const std::string &reason, time_t seconds);
BanCacheHit *GetHit(const std::string &ip);
bool RemoveHit(BanCacheHit *b);
diff --git a/src/bancache.cpp b/src/bancache.cpp
index 3678dda0b..2254a117b 100644
--- a/src/bancache.cpp
+++ b/src/bancache.cpp
@@ -29,6 +29,19 @@ BanCacheHit *BanCacheManager::AddHit(const std::string &ip, const std::string &t
return b;
}
+BanCacheHit *BanCacheManager::AddHit(const std::string &ip, const std::string &type, const std::string &reason, time_t seconds)
+{
+ BanCacheHit *b;
+
+ if (this->BanHash->find(ip) != this->BanHash->end()) // can't have two cache entries on the same IP, sorry..
+ return NULL;
+
+ b = new BanCacheHit(ServerInstance, ip, type, reason, seconds);
+
+ this->BanHash->insert(std::make_pair(ip, b));
+ return b;
+}
+
BanCacheHit *BanCacheManager::GetHit(const std::string &ip)
{
BanCacheHash::iterator i = this->BanHash->find(ip);