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 * ---------------------------------------------------
19 #include "u_listmode.h"
22 /* $ModDesc: Provides support for the +e channel mode */
23 /* $ModDep: ../../include/u_listmode.h */
25 /* Written by Om<om@inspircd.org>, April 2005. */
26 /* Rewritten to use the listmode utility by Om, December 2005 */
27 /* Adapted from m_exception, which was originally based on m_chanprotect and m_silence */
29 // The +e channel mode takes a nick!ident@host, glob patterns allowed,
30 // and if a user matches an entry on the +e list then they can join the channel, overriding any (+b) bans set on them
31 // Now supports CIDR and IP addresses -- Brain
34 /** Handles +e channel mode
36 class BanException : public ListModeBase
39 BanException(InspIRCd* Instance) : ListModeBase(Instance, 'e', "End of Channel Exception List", "348", "349", true) { }
43 class ModuleBanException : public Module
49 ModuleBanException(InspIRCd* Me)
52 be = new BanException(ServerInstance);
53 if (!ServerInstance->AddMode(be, 'e'))
54 throw ModuleException("Could not add new modes!");
55 ServerInstance->PublishInterface("ChannelBanList", this);
58 virtual void Implements(char* List)
60 be->DoImplements(List);
61 List[I_OnRehash] = List[I_OnRequest] = 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 (match(user->GetFullRealHost(), it->mask.c_str()) || match(user->GetFullHost(), it->mask.c_str()) || (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(userrec* user, const std::string ¶m)
115 virtual char* OnRequest(Request* request)
117 ListModeRequest* LM = (ListModeRequest*)request;
118 if (strcmp("LM_CHECKLIST", request->GetId()) == 0)
121 LM->chan->GetExt(be->GetInfoKey(), list);
125 snprintf(mask, MAXBUF, "%s!%s@%s", LM->user->nick, LM->user->ident, LM->user->GetIPString());
126 for (modelist::iterator it = list->begin(); it != list->end(); it++)
128 if (match(LM->user->GetFullRealHost(), it->mask.c_str()) || match(LM->user->GetFullHost(), it->mask.c_str()) || (match(mask, it->mask.c_str(), true)))
130 // They match an entry
131 return (char*)it->mask.c_str();
140 virtual Version GetVersion()
142 return Version(1, 1, 0, 3, VF_COMMON | VF_VENDOR, API_VERSION);
145 virtual ~ModuleBanException()
147 ServerInstance->Modes->DelMode(be);
149 ServerInstance->UnpublishInterface("ChannelBanList", this);
153 MODULE_INIT(ModuleBanException)