From e7106c5cbacc3784386672898b946a3e96305be1 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 25 May 2007 16:42:59 +0000 Subject: Fix for bug #303 reported by HiroP, thanks git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7136 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_banexception.cpp | 2 +- src/modules/m_banredirect.cpp | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/modules/m_banexception.cpp b/src/modules/m_banexception.cpp index d8bda2a85..5dd406e54 100644 --- a/src/modules/m_banexception.cpp +++ b/src/modules/m_banexception.cpp @@ -58,7 +58,7 @@ public: virtual void Implements(char* List) { be->DoImplements(List); - List[I_OnRequest] = List[I_On005Numeric] = List[I_OnCheckBan] = 1; + List[I_OnRehash] = List[I_OnRequest] = List[I_On005Numeric] = List[I_OnCheckBan] = 1; } virtual void On005Numeric(std::string &output) diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index 3a5acfb34..216d3cb57 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -16,6 +16,7 @@ #include "users.h" #include "channels.h" #include "modules.h" +#include "u_listmode.h" /* $ModDesc: Allows an extended ban (+b) syntax redirecting banned users to another channel */ @@ -187,7 +188,8 @@ class ModuleBanRedirect : public Module { BanRedirect* re; bool nofollow; - + Module* ExceptionModule; + public: ModuleBanRedirect(InspIRCd* Me) : Module(Me) @@ -197,11 +199,13 @@ class ModuleBanRedirect : public Module if(!ServerInstance->AddModeWatcher(re)) throw ModuleException("Could not add mode watcher"); + + OnRehash(NULL, ""); } void Implements(char* List) { - List[I_OnUserPreJoin] = List[I_OnChannelDelete] = List[I_OnCleanup] = 1; + List[I_OnRehash] = List[I_OnUserPreJoin] = List[I_OnChannelDelete] = List[I_OnCleanup] = 1; } virtual void OnChannelDelete(chanrec* chan) @@ -254,6 +258,11 @@ class ModuleBanRedirect : public Module } } + virtual void OnRehash(userrec* user, const std::string ¶m) + { + ExceptionModule = ServerInstance->FindModule("m_banexception.so"); + } + virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs) { /* This prevents recursion when a user sets multiple ban redirects in a chain @@ -274,6 +283,15 @@ class ModuleBanRedirect : public Module /* This was replaced with user->MakeHostIP() when I had a snprintf(), but MakeHostIP() doesn't seem to add the nick. * Maybe we should have a GetFullIPHost() or something to match GetFullHost() and GetFullRealHost? */ + + if (ExceptionModule) + { + ListModeRequest n(this, ExceptionModule, user, chan); + /* Users with ban exceptions are allowed to join without being redirected */ + if (n.Send()) + return 0; + } + std::string ipmask(user->nick); ipmask.append(1, '!').append(user->MakeHostIP()); @@ -314,6 +332,11 @@ class ModuleBanRedirect : public Module { return Version(1, 0, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION); } + + Priority Prioritize() + { + return (Priority)ServerInstance->PriorityBefore("m_banexception.so"); + } }; -- cgit v1.2.3