1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
21 #include "u_listmode.h"
24 /* $ModDesc: Provides support for the +e channel mode */
25 /* $ModDep: ../../include/u_listmode.h */
27 /* Written by Om<om@inspircd.org>, April 2005. */
28 /* Rewritten to use the listmode utility by Om, December 2005 */
29 /* Adapted from m_exception, which was originally based on m_chanprotect and m_silence */
31 // The +e channel mode takes a nick!ident@host, glob patterns allowed,
32 // and if a user matches an entry on the +e list then they can join the channel, overriding any (+b) bans set on them
33 // Now supports CIDR and IP addresses -- Brain
36 /** Handles +e channel mode
38 class BanException : public ListModeBase
41 BanException(InspIRCd* Instance) : ListModeBase(Instance, 'e', "End of Channel Exception List", "348", "349", true) { }
45 class ModuleBanException : public Module
51 ModuleBanException(InspIRCd* Me)
54 be = new BanException(ServerInstance);
55 if (!ServerInstance->AddMode(be, 'e'))
56 throw ModuleException("Could not add new modes!");
59 virtual void Implements(char* List)
61 be->DoImplements(List);
62 List[I_On005Numeric] = List[I_OnCheckBan] = 1;
65 virtual void On005Numeric(std::string &output)
67 output.append(" EXCEPTS=e");
70 virtual int OnCheckBan(userrec* user, chanrec* chan)
75 chan->GetExt(be->GetInfoKey(), list);
80 snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
81 for (modelist::iterator it = list->begin(); it != list->end(); it++)
83 if (ServerInstance->MatchText(user->GetFullRealHost(), it->mask) || ServerInstance->MatchText(user->GetFullHost(), it->mask) || (match(mask, it->mask.c_str(), true)))
85 // They match an entry on the list, so let them in.
91 // or if there wasn't a list, there can't be anyone on it, so we don't need to do anything.
96 virtual void OnCleanup(int target_type, void* item)
98 be->DoCleanup(target_type, item);
101 virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque)
103 be->DoSyncChannel(chan, proto, opaque);
106 virtual void OnChannelDelete(chanrec* chan)
108 be->DoChannelDelete(chan);
111 virtual void OnRehash(const std::string ¶m)
116 virtual Version GetVersion()
118 return Version(1, 1, 0, 3, VF_COMMON | VF_VENDOR, API_VERSION);
121 virtual ~ModuleBanException()
123 ServerInstance->Modes->DelMode(be);
128 class ModuleBanExceptionFactory : public ModuleFactory
131 ModuleBanExceptionFactory()
135 ~ModuleBanExceptionFactory()
139 virtual Module* CreateModule(InspIRCd* Me)
141 return new ModuleBanException(Me);
146 extern "C" void * init_module( void )
148 return new ModuleBanExceptionFactory;