#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
{
safei = x;
safei++;
- if (current > x->second->expiry)
+ if (x->second->duration && current > x->second->expiry)
{
ExpireLine(n, x);
}
const time_t current = ServerInstance->Time();
- for (LookupIter i = x->second.begin(); i != x->second.end(); i++)
+ LookupIter safei;
+
+ for (LookupIter i = x->second.begin(); i != x->second.end(); )
{
+ safei = i;
+ safei++;
+
if (i->second->Matches(user))
{
- if (current > i->second->expiry)
+ if (i->second->duration && current > i->second->expiry)
{
/* Expire the line, return nothing */
ExpireLine(x, i);
- return NULL;
+ /* Continue, there may be another that matches
+ * (thanks aquanight)
+ */
+ i = safei;
+ continue;
}
else
return i->second;
}
+
+ i = safei;
}
return NULL;
}
const time_t current = ServerInstance->Time();
- for (LookupIter i = x->second.begin(); i != x->second.end(); i++)
+ LookupIter safei;
+
+ for (LookupIter i = x->second.begin(); i != x->second.end(); )
{
+ safei = i;
+ safei++;
+
if (i->second->Matches(pattern))
{
- if (current > i->second->expiry)
+ if (i->second->duration && current > i->second->expiry)
{
/* Expire the line, return nothing */
ExpireLine(x, i);
- return NULL;
+ /* See above */
+ i = safei;
+ continue;
}
else
return i->second;
}
+
+ i = safei;
}
return NULL;
}
safei = i;
safei++;
- if (current > i->second->expiry)
+ if (i->second->duration && current > i->second->expiry)
{
ExpireLine(n, i);
}
{
}
-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);
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)
void KLine::Apply(User* u)
{
- DefaultApply(u, "K");
+ DefaultApply(u, "K", (strcmp(this->identmask, "*") == 0) ? true : false);
}
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)
void ZLine::Apply(User* u)
{
- DefaultApply(u, "Z");
+ DefaultApply(u, "Z", true);
}
void QLine::Apply(User* u)
{
- /* Can we force the user to their uid here instead? */
- DefaultApply(u, "Q");
+ /* Force to uuid on apply of qline, no need to disconnect any more :) */
+ u->ForceNickChange(u->uuid);
}