2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2017-2019 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2012-2013 Attila Molnar <attilamolnar@hush.com>
6 * Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
8 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
9 * Copyright (C) 2007-2008 Dennis Friis <peavey@inspircd.org>
10 * Copyright (C) 2007 Craig Edwards <brain@inspircd.org>
12 * This file is part of InspIRCd. InspIRCd is free software: you can
13 * redistribute it and/or modify it under the terms of the GNU General Public
14 * License as published by the Free Software Foundation, version 2.
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 /* Written by Om<om@inspircd.org>, April 2005. */
30 /* Rewritten to use the listmode utility by Om, December 2005 */
31 /* Adapted from m_exception, which was originally based on m_chanprotect and m_silence */
33 // The +e channel mode takes a nick!ident@host, glob patterns allowed,
34 // and if a user matches an entry on the +e list then they can join the channel, overriding any (+b) bans set on them
35 // Now supports CIDR and IP addresses -- Brain
38 /** Handles +e channel mode
40 class BanException : public ListModeBase
43 BanException(Module* Creator)
44 : ListModeBase(Creator, "banexception", 'e', "End of Channel Exception List", 348, 349, true)
51 class ModuleBanException : public Module
56 ModuleBanException() : be(this)
60 void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
62 tokens["EXCEPTS"] = ConvToStr(be.GetModeChar());
65 ModResult OnExtBanCheck(User *user, Channel *chan, char type) CXX11_OVERRIDE
67 ListModeBase::ModeList* list = be.GetList(chan);
69 return MOD_RES_PASSTHRU;
71 for (ListModeBase::ModeList::iterator it = list->begin(); it != list->end(); it++)
73 if (it->mask.length() <= 2 || it->mask[0] != type || it->mask[1] != ':')
76 if (chan->CheckBan(user, it->mask.substr(2)))
78 // They match an entry on the list, so let them pass this.
83 return MOD_RES_PASSTHRU;
86 ModResult OnCheckChannelBan(User* user, Channel* chan) CXX11_OVERRIDE
88 ListModeBase::ModeList* list = be.GetList(chan);
91 // No list, proceed normally
92 return MOD_RES_PASSTHRU;
95 for (ListModeBase::ModeList::iterator it = list->begin(); it != list->end(); it++)
97 if (chan->CheckBan(user, it->mask))
99 // They match an entry on the list, so let them in.
100 return MOD_RES_ALLOW;
103 return MOD_RES_PASSTHRU;
106 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
111 Version GetVersion() CXX11_OVERRIDE
113 return Version("Provides channel mode +e, ban exceptions", VF_VENDOR);
117 MODULE_INIT(ModuleBanException)