]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Make sure banredirect metadata can not be duplicated
authorlinuxdaemon <linuxdaemon@snoonet.org>
Thu, 25 Jan 2018 22:07:30 +0000 (16:07 -0600)
committerlinuxdaemon <linuxdaemon@snoonet.org>
Thu, 25 Jan 2018 22:07:30 +0000 (16:07 -0600)
src/modules/m_banredirect.cpp

index 1b9e361bf408dc12fd0697f354323388941a3545..a0c9bc7509ea4ab2b3a6b670538ca7d8cd07525a 100644 (file)
@@ -40,9 +40,17 @@ class BanRedirectEntry
        : targetchan(target), banmask(mask)
        {
        }
+
+       bool operator<(const BanRedirectEntry& other) const
+       {
+               if (this->targetchan < other.targetchan)
+                       return true;
+
+               return this->banmask < other.banmask;
+       }
 };
 
-typedef std::vector<BanRedirectEntry> BanRedirectList;
+typedef std::set<BanRedirectEntry> BanRedirectList;
 typedef std::deque<std::string> StringDeque;
 
 class BanRedirect : public ModeWatcher
@@ -180,7 +188,7 @@ class BanRedirect : public ModeWatcher
                                        }
 
                                        /* Here 'param' doesn't have the channel on it yet */
-                                       redirects->push_back(BanRedirectEntry(mask[CHAN], param));
+                                       redirects->insert(BanRedirectEntry(mask[CHAN], param));
 
                                        /* Now it does */
                                        param.append(mask[CHAN]);
@@ -259,7 +267,7 @@ class ModuleBanRedirect : public Module
 
                                for(BanRedirectList::iterator i = redirects->begin(); i != redirects->end(); i++)
                                {
-                                       modestack.Push('b', i->targetchan.insert(0, i->banmask));
+                                       modestack.Push('b', i->banmask + i->targetchan);
                                }
 
                                for(BanRedirectList::iterator i = redirects->begin(); i != redirects->end(); i++)