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 * ---------------------------------------------------
20 #include "u_listmode.h"
22 /* $ModDesc: Provides support for the +I channel mode */
23 /* $ModDep: ../../include/u_listmode.h */
26 * Written by Om <om@inspircd.org>, April 2005.
27 * Based on m_exception, which was originally based on m_chanprotect and m_silence
29 * The +I channel mode takes a nick!ident@host, glob patterns allowed,
30 * and if a user matches an entry on the +I list then they can join the channel,
31 * ignoring if +i is set on the channel
32 * Now supports CIDR and IP addresses -- Brain
35 class InspIRCd* ServerInstance;
37 /** Handles channel mode +I
39 class InviteException : public ListModeBase
42 InviteException(InspIRCd* Instance) : ListModeBase(Instance, 'I', "End of Channel Invite Exception List", "346", "347", true) { }
45 class ModuleInviteException : public Module
49 ModuleInviteException(InspIRCd* Me) : Module(Me)
51 ie = new InviteException(ServerInstance);
52 if (!ServerInstance->AddMode(ie, 'I'))
53 throw ModuleException("Could not add new modes!");
56 virtual void Implements(char* List)
58 ie->DoImplements(List);
59 List[I_On005Numeric] = List[I_OnCheckInvite] = 1;
62 virtual void On005Numeric(std::string &output)
64 output.append(" INVEX=I");
67 virtual int OnCheckInvite(userrec* user, chanrec* chan)
72 chan->GetExt(ie->GetInfoKey(), list);
76 snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
77 for (modelist::iterator it = list->begin(); it != list->end(); it++)
79 if(match(user->GetFullRealHost(), it->mask.c_str()) || match(user->GetFullHost(), it->mask.c_str()) || (match(mask, it->mask.c_str(), true)))
81 // They match an entry on the list, so let them in.
86 // or if there wasn't a list, there can't be anyone on it, so we don't need to do anything.
92 virtual void OnCleanup(int target_type, void* item)
94 ie->DoCleanup(target_type, item);
97 virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque)
99 ie->DoSyncChannel(chan, proto, opaque);
102 virtual void OnChannelDelete(chanrec* chan)
104 ie->DoChannelDelete(chan);
107 virtual void OnRehash(userrec* user, const std::string ¶m)
112 virtual Version GetVersion()
114 return Version(1, 1, 0, 3, VF_VENDOR | VF_COMMON, API_VERSION);
117 ~ModuleInviteException()
119 ServerInstance->Modes->DelMode(ie);
125 class ModuleInviteExceptionFactory : public ModuleFactory
128 ModuleInviteExceptionFactory()
132 ~ModuleInviteExceptionFactory()
136 virtual Module * CreateModule(InspIRCd* Me)
138 return new ModuleInviteException(Me);
144 extern "C" void * init_module( void )
146 return new ModuleInviteExceptionFactory;