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 */
29 /* Written by Om<om@inspircd.org>, April 2005. */
30 /* Rewritten to use the listmode utility by Om, December 2005 */
31 /* Adapted from m_exception, which was originally based on m_chanprotect and m_silence */
33 // The +e channel mode takes a nick!ident@host, glob patterns allowed,
34 // and if a user matches an entry on the +e list then they can join the channel, overriding any (+b) bans set on them
35 // Now supports CIDR and IP addresses -- Brain
38 /** Handles +e channel mode
40 class BanException : public ListModeBase
43 BanException(InspIRCd* Instance) : ListModeBase(Instance, 'e', "End of Channel Exception List", "348", "349", true) { }
47 class ModuleBanException : public Module
53 ModuleBanException(InspIRCd* Me)
56 be = new BanException(ServerInstance);
57 ServerInstance->AddMode(be, 'e');
60 virtual void Implements(char* List)
62 be->DoImplements(List);
63 List[I_On005Numeric] = List[I_OnCheckBan] = 1;
66 virtual void On005Numeric(std::string &output)
68 output.append(" EXCEPTS=e");
71 virtual int OnCheckBan(userrec* user, chanrec* chan)
76 chan->GetExt(be->GetInfoKey(), list);
81 snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
82 for (modelist::iterator it = list->begin(); it != list->end(); it++)
84 if (ServerInstance->MatchText(user->GetFullRealHost(), it->mask) || ServerInstance->MatchText(user->GetFullHost(), it->mask) || (match(mask, it->mask.c_str(), true)))
86 // They match an entry on the list, so let them in.
92 // or if there wasn't a list, there can't be anyone on it, so we don't need to do anything.
97 virtual void OnCleanup(int target_type, void* item)
99 be->DoCleanup(target_type, item);
102 virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque)
104 be->DoSyncChannel(chan, proto, opaque);
107 virtual void OnChannelDelete(chanrec* chan)
109 be->DoChannelDelete(chan);
112 virtual void OnRehash(const std::string ¶m)
117 virtual Version GetVersion()
119 return Version(1, 0, 0, 3, VF_COMMON | VF_VENDOR, API_VERSION);
122 virtual ~ModuleBanException()
124 ServerInstance->Modes->DelMode(be);
129 class ModuleBanExceptionFactory : public ModuleFactory
132 ModuleBanExceptionFactory()
136 ~ModuleBanExceptionFactory()
140 virtual Module* CreateModule(InspIRCd* Me)
142 return new ModuleBanException(Me);
147 extern "C" void * init_module( void )
149 return new ModuleBanExceptionFactory;