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 */
26 /* $ModDep: ../../include/u_listmode.h */
29 * Written by Om <om@inspircd.org>, April 2005.
30 * Based on m_exception, which was originally based on m_chanprotect and m_silence
32 * The +I channel mode takes a nick!ident@host, glob patterns allowed,
33 * and if a user matches an entry on the +I list then they can join the channel,
34 * ignoring if +i is set on the channel
35 * Now supports CIDR and IP addresses -- Brain
38 class InspIRCd* ServerInstance;
40 /** Handles channel mode +I
42 class InviteException : public ListModeBase
45 InviteException(InspIRCd* Instance) : ListModeBase(Instance, 'I', "End of Channel Invite Exception List", "346", "347", true) { }
48 class ModuleInviteException : public Module
52 ModuleInviteException(InspIRCd* Me) : Module(Me)
54 ie = new InviteException(ServerInstance);
55 ServerInstance->AddMode(ie, 'I');
58 virtual void Implements(char* List)
60 ie->DoImplements(List);
61 List[I_On005Numeric] = List[I_OnCheckInvite] = 1;
64 virtual void On005Numeric(std::string &output)
66 output.append(" INVEX=I");
69 virtual int OnCheckInvite(userrec* user, chanrec* chan)
74 chan->GetExt(ie->GetInfoKey(), list);
78 snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
79 for (modelist::iterator it = list->begin(); it != list->end(); it++)
81 if(match(user->GetFullRealHost(), it->mask.c_str()) || match(user->GetFullHost(), it->mask.c_str()) || (match(mask, it->mask.c_str(), true)))
83 // They match an entry on the list, so let them in.
88 // or if there wasn't a list, there can't be anyone on it, so we don't need to do anything.
94 virtual void OnCleanup(int target_type, void* item)
96 ie->DoCleanup(target_type, item);
99 virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque)
101 ie->DoSyncChannel(chan, proto, opaque);
104 virtual void OnChannelDelete(chanrec* chan)
106 ie->DoChannelDelete(chan);
109 virtual void OnRehash(const std::string ¶m)
114 virtual Version GetVersion()
116 return Version(1, 1, 0, 3, VF_VENDOR | VF_COMMON, API_VERSION);
119 ~ModuleInviteException()
121 ServerInstance->Modes->DelMode(ie);
127 class ModuleInviteExceptionFactory : public ModuleFactory
130 ModuleInviteExceptionFactory()
134 ~ModuleInviteExceptionFactory()
138 virtual Module * CreateModule(InspIRCd* Me)
140 return new ModuleInviteException(Me);
146 extern "C" void * init_module( void )
148 return new ModuleInviteExceptionFactory;