-/* +------------------------------------+\r * | Inspire Internet Relay Chat Daemon |\r * +------------------------------------+\r *\r * InspIRCd: (C) 2002-2007 InspIRCd Development Team\r * See: http://www.inspircd.org/wiki/index.php/Credits\r *\r * This program is free but copyrighted software; see\r * the file COPYING for details.\r *\r * ---------------------------------------------------\r */\r\r#include "inspircd.h"\r#include "users.h"\r#include "channels.h"\r#include "modules.h"\r#include "mode.h"\r#include "u_listmode.h"\r#include "wildcard.h"\r\r/* $ModDesc: Provides support for the +e channel mode */\r/* $ModDep: ../../include/u_listmode.h */\r\r/* Written by Om<om@inspircd.org>, April 2005. */\r/* Rewritten to use the listmode utility by Om, December 2005 */\r/* Adapted from m_exception, which was originally based on m_chanprotect and m_silence */\r\r// The +e channel mode takes a nick!ident@host, glob patterns allowed,\r// and if a user matches an entry on the +e list then they can join the channel, overriding any (+b) bans set on them\r// Now supports CIDR and IP addresses -- Brain\r\r\r/** Handles +e channel mode\r */\rclass BanException : public ListModeBase\r{\r public:\r BanException(InspIRCd* Instance) : ListModeBase(Instance, 'e', "End of Channel Exception List", "348", "349", true) { }\r};\r\r\rclass ModuleBanException : public Module\r{\r BanException* be;\r \r\rpublic:\r ModuleBanException(InspIRCd* Me)\r : Module(Me)\r {\r be = new BanException(ServerInstance);\r if (!ServerInstance->AddMode(be, 'e'))\r throw ModuleException("Could not add new modes!");\r ServerInstance->PublishInterface("ChannelBanList", this);\r }\r \r virtual void Implements(char* List)\r {\r be->DoImplements(List);\r List[I_OnRehash] = List[I_OnRequest] = List[I_On005Numeric] = List[I_OnCheckBan] = 1;\r }\r \r virtual void On005Numeric(std::string &output)\r {\r output.append(" EXCEPTS=e");\r }\r\r virtual int OnCheckBan(userrec* user, chanrec* chan)\r {\r if (chan != NULL)\r {\r modelist* list;\r chan->GetExt(be->GetInfoKey(), list);\r \r if (list)\r {\r char mask[MAXBUF];\r snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());\r for (modelist::iterator it = list->begin(); it != list->end(); it++)\r {\r if (match(user->GetFullRealHost(), it->mask.c_str()) || match(user->GetFullHost(), it->mask.c_str()) || (match(mask, it->mask.c_str(), true)))\r {\r // They match an entry on the list, so let them in.\r return 1;\r }\r }\r return 0;\r }\r // or if there wasn't a list, there can't be anyone on it, so we don't need to do anything.\r }\r return 0; \r }\r\r virtual void OnCleanup(int target_type, void* item)\r {\r be->DoCleanup(target_type, item);\r }\r\r virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque)\r {\r be->DoSyncChannel(chan, proto, opaque);\r }\r\r virtual void OnChannelDelete(chanrec* chan)\r {\r be->DoChannelDelete(chan);\r }\r\r virtual void OnRehash(userrec* user, const std::string ¶m)\r {\r be->DoRehash();\r }\r\r virtual char* OnRequest(Request* request)\r {\r ListModeRequest* LM = (ListModeRequest*)request;\r if (strcmp("LM_CHECKLIST", request->GetId()) == 0)\r {\r modelist* list;\r LM->chan->GetExt(be->GetInfoKey(), list);\r if (list)\r {\r char mask[MAXBUF];\r snprintf(mask, MAXBUF, "%s!%s@%s", LM->user->nick, LM->user->ident, LM->user->GetIPString());\r for (modelist::iterator it = list->begin(); it != list->end(); it++)\r {\r if (match(LM->user->GetFullRealHost(), it->mask.c_str()) || match(LM->user->GetFullHost(), it->mask.c_str()) || (match(mask, it->mask.c_str(), true)))\r {\r // They match an entry\r return (char*)it->mask.c_str();\r }\r }\r return NULL;\r }\r }\r return NULL;\r }\r\r virtual Version GetVersion()\r {\r return Version(1, 1, 0, 3, VF_COMMON | VF_VENDOR, API_VERSION);\r }\r \r virtual ~ModuleBanException()\r {\r ServerInstance->Modes->DelMode(be);\r DELETE(be);\r ServerInstance->UnpublishInterface("ChannelBanList", this);\r }\r};\r\rMODULE_INIT(ModuleBanException)\r
\ No newline at end of file
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
+ * Copyright (C) 2006-2008 Craig Edwards <craigedwards@brainbox.cc>
+ * Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
+ * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ * Copyright (C) 2006 Oliver Lupton <oliverlupton@gmail.com>
+ *
+ * This file is part of InspIRCd. InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "inspircd.h"
+#include "listmode.h"
+
+/* Written by Om<om@inspircd.org>, April 2005. */
+/* Rewritten to use the listmode utility by Om, December 2005 */
+/* Adapted from m_exception, which was originally based on m_chanprotect and m_silence */
+
+// The +e channel mode takes a nick!ident@host, glob patterns allowed,
+// and if a user matches an entry on the +e list then they can join the channel, overriding any (+b) bans set on them
+// Now supports CIDR and IP addresses -- Brain
+
+
+/** Handles +e channel mode
+ */
+class BanException : public ListModeBase
+{
+ public:
+ BanException(Module* Creator) : ListModeBase(Creator, "banexception", 'e', "End of Channel Exception List", 348, 349, true) { }
+};
+
+
+class ModuleBanException : public Module
+{
+ BanException be;
+
+ public:
+ ModuleBanException() : be(this)
+ {
+ }
+
+ void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
+ {
+ tokens["EXCEPTS"] = "e";
+ }
+
+ ModResult OnExtBanCheck(User *user, Channel *chan, char type) CXX11_OVERRIDE
+ {
+ if (chan != NULL)
+ {
+ ListModeBase::ModeList *list = be.GetList(chan);
+
+ if (!list)
+ return MOD_RES_PASSTHRU;
+
+ for (ListModeBase::ModeList::iterator it = list->begin(); it != list->end(); it++)
+ {
+ if (it->mask[0] != type || it->mask[1] != ':')
+ continue;
+
+ if (chan->CheckBan(user, it->mask.substr(2)))
+ {
+ // They match an entry on the list, so let them pass this.
+ return MOD_RES_ALLOW;
+ }
+ }
+ }
+
+ return MOD_RES_PASSTHRU;
+ }
+
+ ModResult OnCheckChannelBan(User* user, Channel* chan) CXX11_OVERRIDE
+ {
+ if (chan)
+ {
+ ListModeBase::ModeList *list = be.GetList(chan);
+
+ if (!list)
+ {
+ // No list, proceed normally
+ return MOD_RES_PASSTHRU;
+ }
+
+ for (ListModeBase::ModeList::iterator it = list->begin(); it != list->end(); it++)
+ {
+ if (chan->CheckBan(user, it->mask))
+ {
+ // They match an entry on the list, so let them in.
+ return MOD_RES_ALLOW;
+ }
+ }
+ }
+ return MOD_RES_PASSTHRU;
+ }
+
+ void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
+ {
+ be.DoRehash();
+ }
+
+ Version GetVersion() CXX11_OVERRIDE
+ {
+ return Version("Provides support for the +e channel mode", VF_VENDOR);
+ }
+};
+
+MODULE_INIT(ModuleBanException)