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 ServerInstance->AddMode(be, 'e');
58 virtual void Implements(char* List)
60 be->DoImplements(List);
61 List[I_On005Numeric] = List[I_OnCheckBan] = 1;
64 virtual void On005Numeric(std::string &output)
66 output.append(" EXCEPTS=e");
69 virtual int OnCheckBan(userrec* user, chanrec* chan)
74 chan->GetExt(be->GetInfoKey(), list);
79 snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
80 for (modelist::iterator it = list->begin(); it != list->end(); it++)
82 if (ServerInstance->MatchText(user->GetFullRealHost(), it->mask) || ServerInstance->MatchText(user->GetFullHost(), it->mask) || (match(mask, it->mask.c_str(), true)))
84 // They match an entry on the list, so let them in.
90 // or if there wasn't a list, there can't be anyone on it, so we don't need to do anything.
95 virtual void OnCleanup(int target_type, void* item)
97 be->DoCleanup(target_type, item);
100 virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque)
102 be->DoSyncChannel(chan, proto, opaque);
105 virtual void OnChannelDelete(chanrec* chan)
107 be->DoChannelDelete(chan);
110 virtual void OnRehash(const std::string ¶m)
115 virtual Version GetVersion()
117 return Version(1, 1, 0, 3, VF_COMMON | VF_VENDOR, API_VERSION);
120 virtual ~ModuleBanException()
122 ServerInstance->Modes->DelMode(be);
127 class ModuleBanExceptionFactory : public ModuleFactory
130 ModuleBanExceptionFactory()
134 ~ModuleBanExceptionFactory()
138 virtual Module* CreateModule(InspIRCd* Me)
140 return new ModuleBanException(Me);
145 extern "C" void * init_module( void )
147 return new ModuleBanExceptionFactory;