From: linuxdaemon Date: Fri, 26 Jan 2018 03:34:40 +0000 (-0600) Subject: Revert std::set changes and add duplicate checking in m_banredirect instead, as reque... X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=219e01b5ce7588efc5da9b8c5d1ce8e7a629b462;p=user%2Fhenk%2Fcode%2Finspircd.git Revert std::set changes and add duplicate checking in m_banredirect instead, as requested by @Adam- --- diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index 64a5855ae..1d35c2934 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -40,17 +40,9 @@ class BanRedirectEntry : targetchan(target), banmask(mask) { } - - bool operator<(const BanRedirectEntry& other) const - { - if (targetchan != other.targetchan) - return targetchan < other.targetchan; - - return banmask < other.banmask; - } }; -typedef std::set BanRedirectList; +typedef std::vector BanRedirectList; typedef std::deque StringDeque; class BanRedirect : public ModeWatcher @@ -186,9 +178,24 @@ 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::string(redir->targetchan.c_str()) == irc::string(mask[CHAN].c_str())) && (irc::string(redir->banmask.c_str()) == irc::string(param.c_str()))) + { + // 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->insert(BanRedirectEntry(mask[CHAN], param)); + redirects->push_back(BanRedirectEntry(mask[CHAN], param)); /* Now it does */ param.append(mask[CHAN]); @@ -267,7 +274,7 @@ class ModuleBanRedirect : public Module for(BanRedirectList::iterator i = redirects->begin(); i != redirects->end(); i++) { - modestack.Push('b', i->banmask + i->targetchan); + modestack.Push('b', i->targetchan.insert(0, i->banmask)); } for(BanRedirectList::iterator i = redirects->begin(); i != redirects->end(); i++)