X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_banredirect.cpp;h=ee52a5cfbb8d058dfad23061c5872e475cf9c224;hb=86f8294c2de86b8d060abbb02f7c51c0ca0d9ead;hp=421d8ade64707d506da989a290fcad872c4c26d8;hpb=553a8da754c8cd308bad2008018849714e70f9b7;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index 421d8ade6..ee52a5cfb 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -139,7 +139,7 @@ class BanRedirect : public ModeWatcher return false; } - Channel *c = ServerInstance->FindChan(mask[CHAN].c_str()); + Channel *c = ServerInstance->FindChan(mask[CHAN]); if (!c) { source->WriteNumeric(690, "%s :Target channel %s must exist to be set as a redirect.",source->nick.c_str(),mask[CHAN].c_str()); @@ -169,7 +169,7 @@ class BanRedirect : public ModeWatcher } /* Here 'param' doesn't have the channel on it yet */ - redirects->push_back(BanRedirectEntry(mask[CHAN].c_str(), param.c_str())); + redirects->push_back(BanRedirectEntry(mask[CHAN], param)); /* Now it does */ param.append(mask[CHAN]); @@ -227,16 +227,9 @@ class ModuleBanRedirect : public Module if(!ServerInstance->Modes->AddModeWatcher(&re)) throw ModuleException("Could not add mode watcher"); - OnRehash(NULL); - - ServerInstance->Extensions.Register(&re.extItem); - Implementation list[] = { I_OnRehash, I_OnUserPreJoin, I_OnChannelDelete }; - ServerInstance->Modules->Attach(list, this, 3); - } - - virtual void OnChannelDelete(Channel* chan) - { - OnCleanup(TYPE_CHANNEL, chan); + ServerInstance->Modules->AddService(re.extItem); + Implementation list[] = { I_OnUserPreJoin }; + ServerInstance->Modules->Attach(list, this, sizeof(list)/sizeof(Implementation)); } virtual void OnCleanup(int target_type, void* item) @@ -274,19 +267,8 @@ class ModuleBanRedirect : public Module } } - virtual void OnRehash(User* user) - { - } - virtual ModResult OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven) { - /* This prevents recursion when a user sets multiple ban redirects in a chain - * (thanks Potter) - */ - if (nofollow) - return MOD_RES_PASSTHRU; - - /* Return 1 to prevent the join, 0 to allow it */ if (chan) { BanRedirectList* redirects = re.extItem.get(chan); @@ -314,6 +296,16 @@ class ModuleBanRedirect : public Module { if(InspIRCd::Match(user->GetFullRealHost(), redir->banmask) || InspIRCd::Match(user->GetFullHost(), redir->banmask) || InspIRCd::MatchCIDR(ipmask, redir->banmask)) { + /* This prevents recursion when a user sets multiple ban redirects in a chain + * (thanks Potter) + * + * If we're here and nofollow is true then we're already redirecting this user + * and there's a redirecting ban set on this channel that matches him, too. + * Deny both joins. + */ + if (nofollow) + return MOD_RES_DENY; + /* tell them they're banned and are being transferred */ Channel* destchan = ServerInstance->FindChan(redir->targetchan); std::string destlimit; @@ -353,12 +345,6 @@ class ModuleBanRedirect : public Module { return Version("Allows an extended ban (+b) syntax redirecting banned users to another channel", VF_COMMON|VF_VENDOR); } - - void Prioritize() - { - Module* banex = ServerInstance->Modules->Find("m_banexception.so"); - ServerInstance->Modules->SetPriority(this, I_OnUserPreJoin, PRIORITY_BEFORE, &banex); - } }; MODULE_INIT(ModuleBanRedirect)