diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-07-11 21:26:27 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-07-11 21:26:27 +0000 |
commit | bd2782b9e80f10f91810fcc819bd6d77f1c991a0 (patch) | |
tree | 2365715d79049aaa38b7d5c320951182a88995f8 | |
parent | 0b070b52bc8e8ceb52388e45cea90f4add119c4f (diff) |
Add OnCheckExtBan, will be used for exceptions to extbans
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9957 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/modules.h | 9 | ||||
-rw-r--r-- | src/channels.cpp | 36 |
2 files changed, 29 insertions, 16 deletions
diff --git a/include/modules.h b/include/modules.h index ca331e334..168bc6c06 100644 --- a/include/modules.h +++ b/include/modules.h @@ -392,7 +392,7 @@ enum Implementation I_OnDecodeMetaData, I_ProtoSendMode, I_ProtoSendMetaData, I_OnWallops, I_OnChangeHost, I_OnChangeName, I_OnAddLine, I_OnDelLine, I_OnExpireLine, I_OnCleanup, I_OnUserPostNick, I_OnAccessCheck, I_On005Numeric, I_OnKill, I_OnRemoteKill, I_OnLoadModule, I_OnUnloadModule, I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite, I_OnRawMode, - I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnStats, I_OnChangeLocalUserHost, I_OnChangeLocalUserGecos, I_OnLocalTopicChange, + I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnCheckExtBan, I_OnStats, I_OnChangeLocalUserHost, I_OnChangeLocalUserGecos, I_OnLocalTopicChange, I_OnPostLocalTopicChange, I_OnEvent, I_OnRequest, I_OnGlobalOper, I_OnPostConnect, I_OnAddBan, I_OnDelBan, I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketWrite, I_OnRawSocketRead, I_OnChangeLocalUserGECOS, I_OnUserRegister, I_OnChannelPreDelete, I_OnChannelDelete, I_OnPostOper, I_OnSyncOtherMetaData, I_OnSetAway, I_OnUserList, @@ -1133,6 +1133,13 @@ class CoreExport Module : public Extensible */ virtual int OnCheckBan(User* user, Channel* chan); + /* Called whenever checking whether or not a user is matched by an applicable extended bantype. + * @param u The user to check + * @param c The channel the user is on + * @param type The type of extended ban to check for. + */ + virtual int OnCheckExtBan(User *u, Channel *c, char type); + /** Called on all /STATS commands * This method is triggered for all /STATS use, including stats symbols handled by the core. * @param symbol the symbol provided to /STATS diff --git a/src/channels.cpp b/src/channels.cpp index 47dfd91b6..d917edb84 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -453,26 +453,32 @@ bool Channel::IsBanned(User* user) bool Channel::IsExtBanned(User *user, char type) { - // XXX. do we need events? char mask[MAXBUF]; + int MOD_RESULT = 0; + FOREACH_RESULT(I_OnCheckExtBan,OnCheckExtBan(user, this, type)); - snprintf(mask, MAXBUF, "%s!%s@%s", user->nick.c_str(), user->ident.c_str(), user->GetIPString()); - - for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++) + if (MOD_RESULT == -1) + return true; + else if (MOD_RESULT == 0) { - if (i->data[0] != type || i->data[1] != ':') - continue; - - // Iterate past char and : to get to the mask without doing a data copy(!) - std::string maskptr = i->data.substr(2); + snprintf(mask, MAXBUF, "%s!%s@%s", user->nick.c_str(), user->ident.c_str(), user->GetIPString()); - /* This allows CIDR ban matching - * - * Full masked host Full unmasked host IP with/without CIDR - */ - if ((match(user->GetFullHost(), maskptr)) || (match(user->GetFullRealHost(), maskptr)) || (match(mask, maskptr, true))) + for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++) { - return true; + if (i->data[0] != type || i->data[1] != ':') + continue; + + // Iterate past char and : to get to the mask without doing a data copy(!) + std::string maskptr = i->data.substr(2); + + /* This allows CIDR ban matching + * + * Full masked host Full unmasked host IP with/without CIDR + */ + if ((match(user->GetFullHost(), maskptr)) || (match(user->GetFullRealHost(), maskptr)) || (match(mask, maskptr, true))) + { + return true; + } } } |