summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2007-11-04 23:04:47 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2007-11-04 23:04:47 +0000
commit880ae2dab166b4c8e72bc85a925c548f3d451a63 (patch)
treedc40b3d9e1ce366a48640fe1c24b23c398e1f85a
parentcd44daa962c7b22f5564a771b78fcc63458b5eb8 (diff)
Integrate K/Gline into the bancache system by making some modifications to DefaultApply method. This means any type of XLine that uses DefaultApply can hook into the bancache system and add positive hits quickly and easily with no modification, which is neat.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8538 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/xline.h3
-rw-r--r--src/users.cpp6
-rw-r--r--src/xline.cpp16
3 files changed, 16 insertions, 9 deletions
diff --git a/include/xline.h b/include/xline.h
index fcbd9134d..91a7e57fb 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -35,8 +35,9 @@ class CoreExport XLine : public classbase
/** Default 'apply' action. Quits the user.
* @param u User to apply the line against
* @param line The line typed, used for display purposes in the quit message
+ * @param bancache If true, the user will be added to the bancache if they match. Else not.
*/
- void DefaultApply(User* u, const std::string &line);
+ void DefaultApply(User* u, const std::string &line, bool bancache);
public:
diff --git a/src/users.cpp b/src/users.cpp
index e21b0d222..8dd3c3bf9 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -861,8 +861,6 @@ void User::AddClient(InspIRCd* Instance, int socket, int port, bool iscached, in
if (r)
{
- Instance->Log(DEBUG, std::string("BanCache: Adding positive hit for ") + New->GetIPString());
- Instance->BanCache->AddHit(New->GetIPString(), "Z", std::string("Z-Lined: ") + r->reason);
r->Apply(New);
return;
}
@@ -965,7 +963,7 @@ void User::FullConnect()
if (!this->exempt)
{
- XLine* r = ServerInstance->XLines->MatchesLine("G",this);
+ GLine *r = (GLine *)ServerInstance->XLines->MatchesLine("G", this);
if (r)
{
@@ -974,7 +972,7 @@ void User::FullConnect()
return;
}
- XLine* n = ServerInstance->XLines->MatchesLine("K",this);
+ KLine *n = (KLine *)ServerInstance->XLines->MatchesLine("K", this);
if (n)
{
diff --git a/src/xline.cpp b/src/xline.cpp
index 56bd029d7..59f94ce88 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -16,6 +16,7 @@
#include "inspircd.h"
#include "wildcard.h"
#include "xline.h"
+#include "bancache.h"
/*
* This is now version 3 of the XLine subsystem, let's see if we can get it as nice and
@@ -383,7 +384,7 @@ void XLine::Apply(User* u)
{
}
-void XLine::DefaultApply(User* u, const std::string &line)
+void XLine::DefaultApply(User* u, const std::string &line, bool bancache)
{
char reason[MAXBUF];
snprintf(reason, MAXBUF, "%s-Lined: %s", line.c_str(), this->reason);
@@ -393,6 +394,13 @@ void XLine::DefaultApply(User* u, const std::string &line)
User::QuitUser(ServerInstance, u, line + "-Lined", reason);
else
User::QuitUser(ServerInstance, u, reason);
+
+
+ if (bancache)
+ {
+ ServerInstance->Log(DEBUG, std::string("BanCache: Adding positive hit (") + line + ") for " + u->GetIPString());
+ ServerInstance->BanCache->AddHit(u->GetIPString(), this->type, line + "-Lined: " + this->reason);
+ }
}
bool KLine::Matches(User *u)
@@ -413,7 +421,7 @@ bool KLine::Matches(User *u)
void KLine::Apply(User* u)
{
- DefaultApply(u, "K");
+ DefaultApply(u, "K", (strcmp(this->identmask, "*") == 0) ? true : false);
}
bool GLine::Matches(User *u)
@@ -434,7 +442,7 @@ bool GLine::Matches(User *u)
void GLine::Apply(User* u)
{
- DefaultApply(u, "G");
+ DefaultApply(u, "G", (strcmp(this->identmask, "*") == 0) ? true : false);
}
bool ELine::Matches(User *u)
@@ -466,7 +474,7 @@ bool ZLine::Matches(User *u)
void ZLine::Apply(User* u)
{
- DefaultApply(u, "Z");
+ DefaultApply(u, "Z", true);
}