1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 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 * ---------------------------------------------------
15 #include "u_listmode.h"
17 /* $ModDesc: Provides support for the +I channel mode */
18 /* $ModDep: ../../include/u_listmode.h */
21 * Written by Om <om@inspircd.org>, April 2005.
22 * Based on m_exception, which was originally based on m_chanprotect and m_silence
24 * The +I channel mode takes a nick!ident@host, glob patterns allowed,
25 * and if a user matches an entry on the +I list then they can join the channel,
26 * ignoring if +i is set on the channel
27 * Now supports CIDR and IP addresses -- Brain
30 class InspIRCd* ServerInstance;
32 /** Handles channel mode +I
34 class InviteException : public ListModeBase
37 InviteException(InspIRCd* Instance) : ListModeBase(Instance, 'I', "End of Channel Invite Exception List", 346, 347, true) { }
40 class ModuleInviteException : public Module
44 ModuleInviteException(InspIRCd* Me) : Module(Me)
46 ie = new InviteException(ServerInstance);
47 if (!ServerInstance->Modes->AddMode(ie))
48 throw ModuleException("Could not add new modes!");
49 ServerInstance->Modules->PublishInterface("ChannelBanList", this);
51 ie->DoImplements(this);
52 Implementation eventlist[] = { I_OnRequest, I_On005Numeric, I_OnCheckInvite };
53 ServerInstance->Modules->Attach(eventlist, this, 3);
56 virtual void On005Numeric(std::string &output)
58 output.append(" INVEX=I");
61 virtual int OnCheckInvite(User* user, Channel* chan)
66 chan->GetExt(ie->GetInfoKey(), list);
69 std::string mask = std::string(user->nick) + "!" + user->ident + "@" + user->GetIPString();
70 for (modelist::iterator it = list->begin(); it != list->end(); it++)
72 if(InspIRCd::Match(user->GetFullRealHost(), it->mask) || InspIRCd::Match(user->GetFullHost(), it->mask) || (InspIRCd::MatchCIDR(mask, it->mask)))
74 // They match an entry on the list, so let them in.
79 // or if there wasn't a list, there can't be anyone on it, so we don't need to do anything.
85 virtual const char* OnRequest(Request* request)
87 return ie->DoOnRequest(request);
90 virtual void OnCleanup(int target_type, void* item)
92 ie->DoCleanup(target_type, item);
95 virtual void OnSyncChannel(Channel* chan, Module* proto, void* opaque)
97 ie->DoSyncChannel(chan, proto, opaque);
100 virtual void OnChannelDelete(Channel* chan)
102 ie->DoChannelDelete(chan);
105 virtual void OnRehash(User* user, const std::string ¶m)
110 virtual Version GetVersion()
112 return Version("$Id$", VF_VENDOR | VF_COMMON, API_VERSION);
115 ~ModuleInviteException()
117 ServerInstance->Modes->DelMode(ie);
119 ServerInstance->Modules->UnpublishInterface("ChannelBanList", this);
123 MODULE_INIT(ModuleInviteException)