]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Okay, and there's the working version of it. Extbans that don't work on users have...
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 12 Jul 2008 20:53:19 +0000 (20:53 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 12 Jul 2008 20:53:19 +0000 (20:53 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9988 e03df62e-2008-0410-955e-edbf42e46eb7

include/modules.h
src/channels.cpp
src/modules.cpp

index 168bc6c067e3cf64ae3e05084767832f09e48ed8..7945a33ad02eb9e357ebcb54cc736dde67c9dd93 100644 (file)
@@ -392,8 +392,8 @@ 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_OnCheckExtBan, I_OnStats, I_OnChangeLocalUserHost, I_OnChangeLocalUserGecos, I_OnLocalTopicChange,
-       I_OnPostLocalTopicChange, I_OnEvent, I_OnRequest, I_OnGlobalOper, I_OnPostConnect, I_OnAddBan, I_OnDelBan,
+       I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnCheckExtBan, I_OnCheckStringExtBan, 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,
        I_OnPostCommand, I_OnPostJoin, I_OnWhoisLine, I_OnBuildExemptList, I_OnRawSocketConnect, I_OnGarbageCollect, I_OnBufferFlushed,
@@ -1134,12 +1134,18 @@ 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.
+        * NOTE: may also trigger extra OnCheckStringExtBan events!
         * @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 whenever checking whether or not a string is extbanned. NOTE: one OnCheckExtBan will also trigger a number of
+        * OnCheckStringExtBan events for seperate host/IP comnbinations.
+        */
+       virtual int OnCheckStringExtBan(const std::string &s, 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
index 7fd1036d236004fc446f95ac0e15af686c26c258..e9d7f4a272339e3920c386540d96163cf4354488 100644 (file)
@@ -453,14 +453,13 @@ bool Channel::IsBanned(User* user)
 
 bool Channel::IsExtBanned(const std::string &str, char type)
 {
-// XXX XXX XXX need to figure out how to get this to work with string types...
-//     int MOD_RESULT = 0;
-//     FOREACH_RESULT(I_OnCheckExtBan,OnCheckExtBan(user, this, type));
-
-//     if (MOD_RESULT == -1)
-//             return true;
-//     else if (MOD_RESULT == 0)
-//     {
+       int MOD_RESULT = 0;
+       FOREACH_RESULT(I_OnCheckStringExtBan, OnCheckStringExtBan(str, this, type));
+
+       if (MOD_RESULT == -1)
+               return true;
+       else if (MOD_RESULT == 0)
+       {
                for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
                {
                        if (i->data[0] != type || i->data[1] != ':')
@@ -472,40 +471,32 @@ bool Channel::IsExtBanned(const std::string &str, char type)
                        if (match(str, maskptr))
                                return true;
                }
-//     }
+       }
 
        return false;
 }
 
 bool Channel::IsExtBanned(User *user, char type)
 {
-       char mask[MAXBUF];
        int MOD_RESULT = 0;
-       FOREACH_RESULT(I_OnCheckExtBan,OnCheckExtBan(user, this, type));
+       FOREACH_RESULT(I_OnCheckExtBan, OnCheckExtBan(user, this, type));
 
        if (MOD_RESULT == -1)
                return true;
        else if (MOD_RESULT == 0)
        {
+               char mask[MAXBUF];
                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 (i->data[0] != type || i->data[1] != ':')
-                               continue;
+               // XXX: we should probably hook cloaked hosts in here somehow too..
+               if (this->IsExtBanned(mask, type))
+                       return true;
 
-                       // Iterate past char and : to get to the mask without doing a data copy(!)
-                       std::string maskptr = i->data.substr(2);
+               if (this->IsExtBanned(user->GetFullHost(), type))
+                       return true;
 
-                       /* 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;
-                       }
-               }
+               if (this->IsExtBanned(user->GetFullRealHost(), type))
+                       return true;
        }
 
        return false;
index d3de60f6a850d6399b1b0859c1f40df76cb673c4..8d6f3f9a1f0166519067c5807ecf003c47200f3c 100644 (file)
@@ -144,6 +144,7 @@ int         Module::OnCheckKey(User*, Channel*, const std::string&) { return 0; }
 int            Module::OnCheckLimit(User*, Channel*) { return 0; }
 int            Module::OnCheckBan(User*, Channel*) { return 0; }
 int            Module::OnCheckExtBan(User *, Channel *, char) { return 0; }
+int            Module::OnCheckStringExtBan(const std::string &s, Channel *c, char type) { return 0; }
 int            Module::OnStats(char, User*, string_list&) { return 0; }
 int            Module::OnChangeLocalUserHost(User*, const std::string&) { return 0; }
 int            Module::OnChangeLocalUserGECOS(User*, const std::string&) { return 0; }