1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
15 #include "u_listmode.h"
17 /* $ModDesc: Provides support for the +e channel mode */
18 /* $ModDep: ../../include/u_listmode.h */
20 /* Written by Om<om@inspircd.org>, April 2005. */
21 /* Rewritten to use the listmode utility by Om, December 2005 */
22 /* Adapted from m_exception, which was originally based on m_chanprotect and m_silence */
24 // The +e channel mode takes a nick!ident@host, glob patterns allowed,
25 // and if a user matches an entry on the +e list then they can join the channel, overriding any (+b) bans set on them
26 // Now supports CIDR and IP addresses -- Brain
29 /** Handles +e channel mode
31 class BanException : public ListModeBase
34 BanException(Module* Creator) : ListModeBase(Creator, "banexception", 'e', "End of Channel Exception List", 348, 349, true) { }
38 class ModuleBanException : public Module
43 ModuleBanException() : be(this)
45 if (!ServerInstance->Modes->AddMode(&be))
46 throw ModuleException("Could not add new modes!");
48 be.DoImplements(this);
49 Implementation list[] = { I_OnRehash, I_On005Numeric, I_OnExtBanCheck, I_OnCheckChannelBan };
50 ServerInstance->Modules->Attach(list, this, 4);
54 void On005Numeric(std::string &output)
56 output.append(" EXCEPTS=e");
59 ModResult OnExtBanCheck(User *user, Channel *chan, char type)
63 modelist *list = be.extItem.get(chan);
66 return MOD_RES_PASSTHRU;
68 for (modelist::iterator it = list->begin(); it != list->end(); it++)
70 if (it->mask[0] != type || it->mask[1] != ':')
73 if (chan->CheckBan(user, it->mask.substr(2)))
75 // They match an entry on the list, so let them pass this.
81 return MOD_RES_PASSTHRU;
84 ModResult OnCheckChannelBan(User* user, Channel* chan)
88 modelist *list = be.extItem.get(chan);
92 // No list, proceed normally
93 return MOD_RES_PASSTHRU;
96 for (modelist::iterator it = list->begin(); it != list->end(); it++)
98 if (chan->CheckBan(user, it->mask))
100 // They match an entry on the list, so let them in.
101 return MOD_RES_ALLOW;
105 return MOD_RES_PASSTHRU;
108 void OnCleanup(int target_type, void* item)
110 be.DoCleanup(target_type, item);
113 void OnSyncChannel(Channel* chan, Module* proto, void* opaque)
115 be.DoSyncChannel(chan, proto, opaque);
118 void OnRehash(User* user)
125 return Version("Provides support for the +e channel mode", VF_VENDOR);
129 MODULE_INIT(ModuleBanException)