1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
24 #include "u_listmode.h"
27 /* $ModDesc: Provides support for the +e channel mode */
28 /* $ModDep: ../../include/u_listmode.h */
30 /* Written by Om<om@inspircd.org>, April 2005. */
31 /* Rewritten to use the listmode utility by Om, December 2005 */
32 /* Adapted from m_exception, which was originally based on m_chanprotect and m_silence */
34 // The +e channel mode takes a nick!ident@host, glob patterns allowed,
35 // and if a user matches an entry on the +e list then they can join the channel, overriding any (+b) bans set on them
36 // Now supports CIDR and IP addresses -- Brain
39 /** Handles +e channel mode
41 class BanException : public ListModeBase
44 BanException(InspIRCd* Instance) : ListModeBase(Instance, 'e', "End of Channel Exception List", "348", "349", true) { }
48 class ModuleBanException : public Module
54 ModuleBanException(InspIRCd* Me)
57 be = new BanException(ServerInstance);
58 ServerInstance->AddMode(be, 'e');
61 virtual void Implements(char* List)
63 be->DoImplements(List);
64 List[I_On005Numeric] = List[I_OnCheckBan] = 1;
67 virtual void On005Numeric(std::string &output)
69 output.append(" EXCEPTS=e");
72 virtual int OnCheckBan(userrec* user, chanrec* chan)
77 chan->GetExt(be->GetInfoKey(), list);
82 snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
83 for (modelist::iterator it = list->begin(); it != list->end(); it++)
85 if (ServerInstance->MatchText(user->GetFullRealHost(), it->mask) || ServerInstance->MatchText(user->GetFullHost(), it->mask) || (match(mask, it->mask.c_str(), true)))
87 // They match an entry on the list, so let them in.
93 // or if there wasn't a list, there can't be anyone on it, so we don't need to do anything.
98 virtual void OnCleanup(int target_type, void* item)
100 be->DoCleanup(target_type, item);
103 virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque)
105 be->DoSyncChannel(chan, proto, opaque);
108 virtual void OnChannelDelete(chanrec* chan)
110 be->DoChannelDelete(chan);
113 virtual void OnRehash(const std::string ¶m)
118 virtual Version GetVersion()
120 return Version(1, 1, 0, 3, VF_COMMON | VF_VENDOR, API_VERSION);
123 virtual ~ModuleBanException()
125 ServerInstance->Modes->DelMode(be);
130 class ModuleBanExceptionFactory : public ModuleFactory
133 ModuleBanExceptionFactory()
137 ~ModuleBanExceptionFactory()
141 virtual Module* CreateModule(InspIRCd* Me)
143 return new ModuleBanException(Me);
148 extern "C" void * init_module( void )
150 return new ModuleBanExceptionFactory;