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 * ---------------------------------------------------
23 #include "u_listmode.h"
25 /* $ModDesc: Provides support for the +I channel mode */
28 * Written by Om <om@inspircd.org>, April 2005.
29 * Based on m_exception, which was originally based on m_chanprotect and m_silence
31 * The +I channel mode takes a nick!ident@host, glob patterns allowed,
32 * and if a user matches an entry on the +I list then they can join the channel,
33 * ignoring if +i is set on the channel
34 * Now supports CIDR and IP addresses -- Brain
37 class InspIRCd* ServerInstance;
39 /** Handles channel mode +I
41 class InviteException : public ListModeBase
44 InviteException(InspIRCd* Instance) : ListModeBase(Instance, 'I', "End of Channel Invite Exception List", "346", "347", true) { }
47 class ModuleInviteException : public Module
51 ModuleInviteException(InspIRCd* Me) : Module(Me)
53 ie = new InviteException(ServerInstance);
54 ServerInstance->AddMode(ie, 'I');
57 virtual void Implements(char* List)
59 ie->DoImplements(List);
60 List[I_On005Numeric] = List[I_OnCheckInvite] = 1;
63 virtual void On005Numeric(std::string &output)
65 output.append(" INVEX=I");
68 virtual int OnCheckInvite(userrec* user, chanrec* chan)
73 chan->GetExt(ie->GetInfoKey(), list);
77 snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
78 for (modelist::iterator it = list->begin(); it != list->end(); it++)
80 if(match(user->GetFullRealHost(), it->mask.c_str()) || match(user->GetFullHost(), it->mask.c_str()) || (match(mask, it->mask.c_str(), true)))
82 // They match an entry on the list, so let them in.
87 // or if there wasn't a list, there can't be anyone on it, so we don't need to do anything.
93 virtual void OnCleanup(int target_type, void* item)
95 ie->DoCleanup(target_type, item);
98 virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque)
100 ie->DoSyncChannel(chan, proto, opaque);
103 virtual void OnChannelDelete(chanrec* chan)
105 ie->DoChannelDelete(chan);
108 virtual void OnRehash(const std::string ¶m)
113 virtual Version GetVersion()
115 return Version(1, 0, 0, 3, VF_VENDOR | VF_COMMON);
118 ~ModuleInviteException()
120 ServerInstance->Modes->DelMode(ie);
126 class ModuleInviteExceptionFactory : public ModuleFactory
129 ModuleInviteExceptionFactory()
133 ~ModuleInviteExceptionFactory()
137 virtual Module * CreateModule(InspIRCd* Me)
139 return new ModuleInviteException(Me);
145 extern "C" void * init_module( void )
147 return new ModuleInviteExceptionFactory;