#include "socketengine.h"
#include "wildcard.h"
#include "xline.h"
+#include "bancache.h"
#include "commands/cmd_whowas.h"
static unsigned long already_sent[MAX_DESCRIPTORS] = {0};
return;
}
#endif
+ /*
+ * even with bancache, we still have to keep User::exempt current.
+ * besides that, if we get a positive bancache hit, we still won't fuck
+ * them over if they are exempt. -- w00t
+ */
+ New->exempt = (Instance->XLines->MatchesLine("E",New) != NULL);
- New->exempt = (Instance->XLines->matches_exception(New) != NULL);
- if (!New->exempt)
+ if (BanCacheHit *b = Instance->BanCache->GetHit(New->GetIPString()))
{
- ZLine* r = Instance->XLines->matches_zline(ipaddr);
- if (r)
+ if (!b->Type.empty() && !New->exempt)
{
- char reason[MAXBUF];
+ /* user banned */
+ Instance->Log(DEBUG, std::string("BanCache: Positive hit for ") + New->GetIPString());
if (*Instance->Config->MoronBanner)
New->WriteServ("NOTICE %s :*** %s", New->nick, Instance->Config->MoronBanner);
- snprintf(reason,MAXBUF,"Z-Lined: %s",r->reason);
- User::QuitUser(Instance, New, reason);
+ User::QuitUser(Instance, New, b->Reason);
return;
}
+ else
+ {
+ Instance->Log(DEBUG, std::string("BanCache: Negative hit for ") + New->GetIPString());
+ }
+ }
+ else
+ {
+ if (!New->exempt)
+ {
+ XLine* r = Instance->XLines->MatchesLine("Z",New);
+
+ 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;
+ }
+ }
}
if (socket > -1)
if (!this->exempt)
{
- GLine* r = ServerInstance->XLines->matches_gline(this);
+ XLine* r = ServerInstance->XLines->MatchesLine("G",this);
if (r)
{
this->muted = true;
- char reason[MAXBUF];
- if (*ServerInstance->Config->MoronBanner)
- this->WriteServ("NOTICE %s :*** %s", this->nick, ServerInstance->Config->MoronBanner);
- snprintf(reason,MAXBUF,"G-Lined: %s",r->reason);
- User::QuitUser(ServerInstance, this, reason);
+ r->Apply(this);
return;
}
- KLine* n = ServerInstance->XLines->matches_kline(this);
+ XLine* n = ServerInstance->XLines->MatchesLine("K",this);
if (n)
{
this->muted = true;
- char reason[MAXBUF];
- if (*ServerInstance->Config->MoronBanner)
- this->WriteServ("NOTICE %s :*** %s", this, ServerInstance->Config->MoronBanner);
- snprintf(reason,MAXBUF,"K-Lined: %s",n->reason);
- User::QuitUser(ServerInstance, this, reason);
+ n->Apply(this);
return;
}
}
return false;
}
- if (ServerInstance->XLines->matches_qline(newnick))
+ if (ServerInstance->XLines->MatchesLine("Q",newnick))
{
ServerInstance->stats->statsCollisions++;
return false;
if (found)
{
/* deny change if change will take class over the limit */
- if (found->RefCount + 1 >= found->limit)
+ if (found->limit && (found->RefCount + 1 >= found->limit))
{
ServerInstance->Log(DEBUG, "OOPS: Connect class limit (%u) hit, denying", found->limit);
return this->MyClass;