1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 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!");
47 ServerInstance->Modules->PublishInterface("ChannelBanList", this);
49 be.DoImplements(this);
50 Implementation list[] = { I_OnRehash, I_On005Numeric, I_OnExtBanCheck, I_OnCheckChannelBan };
51 ServerInstance->Modules->Attach(list, this, 4);
55 void On005Numeric(std::string &output)
57 output.append(" EXCEPTS=e");
60 ModResult OnExtBanCheck(User *user, Channel *chan, char type)
64 modelist *list = be.extItem.get(chan);
67 return MOD_RES_PASSTHRU;
69 for (modelist::iterator it = list->begin(); it != list->end(); it++)
71 if (it->mask[0] != type || it->mask[1] != ':')
74 if (chan->CheckBan(user, it->mask.substr(2)))
76 // They match an entry on the list, so let them pass this.
82 return MOD_RES_PASSTHRU;
85 ModResult OnCheckChannelBan(User* user, Channel* chan)
89 modelist *list = be.extItem.get(chan);
93 // No list, proceed normally
94 return MOD_RES_PASSTHRU;
97 for (modelist::iterator it = list->begin(); it != list->end(); it++)
99 if (chan->CheckBan(user, it->mask))
101 // They match an entry on the list, so let them in.
102 return MOD_RES_ALLOW;
106 return MOD_RES_PASSTHRU;
109 void OnCleanup(int target_type, void* item)
111 be.DoCleanup(target_type, item);
114 void OnSyncChannel(Channel* chan, Module* proto, void* opaque)
116 be.DoSyncChannel(chan, proto, opaque);
119 void OnRehash(User* user)
126 return Version("Provides support for the +e channel mode", VF_COMMON | VF_VENDOR, API_VERSION);
129 ~ModuleBanException()
131 ServerInstance->Modules->UnpublishInterface("ChannelBanList", this);
135 MODULE_INIT(ModuleBanException)