diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-11-04 13:44:26 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-11-04 13:44:26 +0000 |
commit | 5a5d25304c6278d7f0a4721c280267a0b7370297 (patch) | |
tree | c3bb838b893fc1d21640f12050911939eeaadc2c /src | |
parent | 9f936a78301ebc7e42c0879101fe20599285b84c (diff) |
Hook BanCache up to work on Z:Lines. BanCache is checked first, for positive hits, users are quit instantly. For negative hits, no checking is done (though we don't have any negative hits just yet). If no hit, zlines are checked -- if user is matched by a Z:, positive bancache entry is inserted.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8492 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/users.cpp | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/src/users.cpp b/src/users.cpp index 3803a7a9e..f38b2ca46 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -18,6 +18,7 @@ #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}; @@ -829,21 +830,47 @@ void User::AddClient(InspIRCd* Instance, int socket, int port, bool iscached, in 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); - if (!New->exempt) - { - XLine* r = Instance->XLines->MatchesLine("Z",New); - if (r) + if (BanCacheHit *b = Instance->BanCache->GetHit(New->GetIPString())) + { + if (!b->Type.empty()) { - 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); + char reason[MAXBUF]; + 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); + return; + } + } } if (socket > -1) |