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 * ---------------------------------------------------
15 #include "u_listmode.h"
18 /* $ModDesc: Provides support for the +e channel mode */
19 /* $ModDep: ../../include/u_listmode.h */
21 /* Written by Om<om@inspircd.org>, April 2005. */
22 /* Rewritten to use the listmode utility by Om, December 2005 */
23 /* Adapted from m_exception, which was originally based on m_chanprotect and m_silence */
25 // The +e channel mode takes a nick!ident@host, glob patterns allowed,
26 // and if a user matches an entry on the +e list then they can join the channel, overriding any (+b) bans set on them
27 // Now supports CIDR and IP addresses -- Brain
30 /** Handles +e channel mode
32 class BanException : public ListModeBase
35 BanException(InspIRCd* Instance) : ListModeBase(Instance, 'e', "End of Channel Exception List", "348", "349", true) { }
39 class ModuleBanException : public Module
45 ModuleBanException(InspIRCd* Me)
48 be = new BanException(ServerInstance);
49 if (!ServerInstance->AddMode(be, 'e'))
50 throw ModuleException("Could not add new modes!");
51 ServerInstance->PublishInterface("ChannelBanList", this);
54 virtual void Implements(char* List)
56 be->DoImplements(List);
57 List[I_OnRehash] = List[I_OnRequest] = List[I_On005Numeric] = List[I_OnCheckBan] = 1;
60 virtual void On005Numeric(std::string &output)
62 output.append(" EXCEPTS=e");
65 virtual int OnCheckBan(userrec* user, chanrec* chan)
70 chan->GetExt(be->GetInfoKey(), list);
75 snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
76 for (modelist::iterator it = list->begin(); it != list->end(); it++)
78 if (match(user->GetFullRealHost(), it->mask.c_str()) || match(user->GetFullHost(), it->mask.c_str()) || (match(mask, it->mask.c_str(), true)))
80 // 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.
91 virtual void OnCleanup(int target_type, void* item)
93 be->DoCleanup(target_type, item);
96 virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque)
98 be->DoSyncChannel(chan, proto, opaque);
101 virtual void OnChannelDelete(chanrec* chan)
103 be->DoChannelDelete(chan);
106 virtual void OnRehash(userrec* user, const std::string ¶m)
111 virtual char* OnRequest(Request* request)
113 ListModeRequest* LM = (ListModeRequest*)request;
114 if (strcmp("LM_CHECKLIST", request->GetId()) == 0)
117 LM->chan->GetExt(be->GetInfoKey(), list);
121 snprintf(mask, MAXBUF, "%s!%s@%s", LM->user->nick, LM->user->ident, LM->user->GetIPString());
122 for (modelist::iterator it = list->begin(); it != list->end(); it++)
124 if (match(LM->user->GetFullRealHost(), it->mask.c_str()) || match(LM->user->GetFullHost(), it->mask.c_str()) || (match(mask, it->mask.c_str(), true)))
126 // They match an entry
127 return (char*)it->mask.c_str();
136 virtual Version GetVersion()
138 return Version(1, 1, 0, 3, VF_COMMON | VF_VENDOR, API_VERSION);
141 virtual ~ModuleBanException()
143 ServerInstance->Modes->DelMode(be);
145 ServerInstance->UnpublishInterface("ChannelBanList", this);
149 MODULE_INIT(ModuleBanException)