]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_banredirect.cpp
Update the cloaks of connected users when their IP address changes.
[user/henk/code/inspircd.git] / src / modules / m_banredirect.cpp
index f98cbd420176549147089a361a9f6e1b3312629a..7246527d35ad9b3668f2929ce0ecd2b6ce31f12c 100644 (file)
@@ -54,7 +54,7 @@ class BanRedirect : public ModeWatcher
        {
        }
 
-       bool BeforeMode(User* source, User* dest, Channel* channel, std::string &param, bool adding)
+       bool BeforeMode(User* source, User* dest, Channel* channel, std::string& param, bool adding) CXX11_OVERRIDE
        {
                /* nick!ident@host -> nick!ident@host
                 * nick!ident@host#chan -> nick!ident@host#chan
@@ -82,7 +82,7 @@ class BanRedirect : public ModeWatcher
                        ListModeBase::ModeList* list = banlm->GetList(channel);
                        if ((list) && (adding) && (maxbans <= list->size()))
                        {
-                               source->WriteNumeric(ERR_BANLISTFULL, channel->name, InspIRCd::Format("Channel ban list for %s is full (maximum entries for this channel is %u)", channel->name.c_str(), maxbans));
+                               source->WriteNumeric(ERR_BANLISTFULL, channel->name, banlm->GetModeChar(), InspIRCd::Format("Channel ban list for %s is full (maximum entries for this channel is %u)", channel->name.c_str(), maxbans));
                                return false;
                        }
 
@@ -182,6 +182,21 @@ class BanRedirect : public ModeWatcher
                                                redirects = new BanRedirectList;
                                                extItem.set(channel, redirects);
                                        }
+                                       else
+                                       {
+                                               for (BanRedirectList::iterator redir = redirects->begin(); redir != redirects->end(); ++redir)
+                                               {
+                                                       // Mimic the functionality used when removing the mode
+                                                       if (irc::equals(redir->targetchan, mask[CHAN]) && irc::equals(redir->banmask, param))
+                                                       {
+                                                               // Make sure the +b handler will still set the right ban
+                                                               param.append(mask[CHAN]);
+                                                               // Silently ignore the duplicate and don't set metadata
+                                                               // This still allows channel ops to set/unset a redirect ban to clear "ghost" redirects
+                                                               return true;
+                                                       }
+                                               }
+                                       }
 
                                        /* Here 'param' doesn't have the channel on it yet */
                                        redirects->push_back(BanRedirectEntry(mask[CHAN], param));
@@ -239,9 +254,9 @@ class ModuleBanRedirect : public Module
        {
        }
 
-       void OnCleanup(int target_type, void* item) CXX11_OVERRIDE
+       void OnCleanup(ExtensionItem::ExtensibleType type, Extensible* item) CXX11_OVERRIDE
        {
-               if(target_type == TYPE_CHANNEL)
+               if (type == ExtensionItem::EXT_CHANNEL)
                {
                        Channel* chan = static_cast<Channel*>(item);
                        BanRedirectList* redirects = re.extItem.get(chan);
@@ -308,7 +323,7 @@ class ModuleBanRedirect : public Module
                                                if (destchan)
                                                        destlimit = destchan->GetModeParameter(limitmode);
 
-                                               if(destchan && destchan->IsModeSet(redirectmode) && !destlimit.empty() && (destchan->GetUserCounter() >= atoi(destlimit.c_str())))
+                                               if(destchan && destchan->IsModeSet(redirectmode) && !destlimit.empty() && (destchan->GetUserCounter() >= ConvToNum<size_t>(destlimit)))
                                                {
                                                        user->WriteNumeric(ERR_BANNEDFROMCHAN, chan->name, "Cannot join channel (You are banned)");
                                                        return MOD_RES_DENY;