-/* +------------------------------------+\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\r/* $ModDesc: Provides support for the +I channel mode */\r/* $ModDep: ../../include/u_listmode.h */\r\r/*\r * Written by Om <om@inspircd.org>, April 2005.\r * Based on m_exception, which was originally based on m_chanprotect and m_silence\r *\r * The +I channel mode takes a nick!ident@host, glob patterns allowed,\r * and if a user matches an entry on the +I list then they can join the channel,\r * ignoring if +i is set on the channel\r * Now supports CIDR and IP addresses -- Brain\r */\r\rclass InspIRCd* ServerInstance;\r\r/** Handles channel mode +I\r */\rclass InviteException : public ListModeBase\r{\r public:\r InviteException(InspIRCd* Instance) : ListModeBase(Instance, 'I', "End of Channel Invite Exception List", "346", "347", true) { }\r};\r\rclass ModuleInviteException : public Module\r{\r InviteException* ie;\rpublic:\r ModuleInviteException(InspIRCd* Me) : Module(Me)\r {\r ie = new InviteException(ServerInstance);\r if (!ServerInstance->AddMode(ie, 'I'))\r throw ModuleException("Could not add new modes!");\r ServerInstance->PublishInterface("ChannelBanList", this);\r }\r\r virtual void Implements(char* List)\r {\r ie->DoImplements(List);\r List[I_OnRequest] = List[I_On005Numeric] = List[I_OnCheckInvite] = 1;\r }\r \r virtual void On005Numeric(std::string &output)\r {\r output.append(" INVEX=I");\r }\r \r virtual int OnCheckInvite(userrec* user, chanrec* chan)\r {\r if(chan != NULL)\r {\r modelist* list;\r chan->GetExt(ie->GetInfoKey(), list);\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 }\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\r return 0; \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(ie->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 void OnCleanup(int target_type, void* item)\r {\r ie->DoCleanup(target_type, item);\r }\r\r virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque)\r {\r ie->DoSyncChannel(chan, proto, opaque);\r }\r\r virtual void OnChannelDelete(chanrec* chan)\r {\r ie->DoChannelDelete(chan);\r }\r\r virtual void OnRehash(userrec* user, const std::string ¶m)\r {\r ie->DoRehash();\r }\r \r virtual Version GetVersion()\r {\r return Version(1, 1, 0, 3, VF_VENDOR | VF_COMMON, API_VERSION);\r }\r\r ~ModuleInviteException()\r {\r ServerInstance->Modes->DelMode(ie);\r DELETE(ie);\r ServerInstance->UnpublishInterface("ChannelBanList", this);\r }\r};\r\rMODULE_INIT(ModuleInviteException)\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 Dennis Friis <peavey@inspircd.org>
+ * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
+ * 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.
+ * Based on m_exception, which was originally based on m_chanprotect and m_silence
+ *
+ * The +I channel mode takes a nick!ident@host, glob patterns allowed,
+ * and if a user matches an entry on the +I list then they can join the channel,
+ * ignoring if +i is set on the channel
+ * Now supports CIDR and IP addresses -- Brain
+ */
+
+/** Handles channel mode +I
+ */
+class InviteException : public ListModeBase
+{
+ public:
+ InviteException(Module* Creator)
+ : ListModeBase(Creator, "invex", 'I', "End of Channel Invite Exception List", 346, 347, true)
+ {
+ }
+};
+
+class ModuleInviteException : public Module
+{
+ bool invite_bypass_key;
+ InviteException ie;
+public:
+ ModuleInviteException() : ie(this)
+ {
+ }
+
+ void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
+ {
+ tokens["INVEX"] = ConvToStr(ie.GetModeChar());
+ }
+
+ ModResult OnCheckInvite(User* user, Channel* chan) CXX11_OVERRIDE
+ {
+ ListModeBase::ModeList* list = ie.GetList(chan);
+ if (list)
+ {
+ for (ListModeBase::ModeList::iterator it = list->begin(); it != list->end(); it++)
+ {
+ if (chan->CheckBan(user, it->mask))
+ {
+ return MOD_RES_ALLOW;
+ }
+ }
+ }
+
+ return MOD_RES_PASSTHRU;
+ }
+
+ ModResult OnCheckKey(User* user, Channel* chan, const std::string& key) CXX11_OVERRIDE
+ {
+ if (invite_bypass_key)
+ return OnCheckInvite(user, chan);
+ return MOD_RES_PASSTHRU;
+ }
+
+ void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
+ {
+ ie.DoRehash();
+ invite_bypass_key = ServerInstance->Config->ConfValue("inviteexception")->getBool("bypasskey", true);
+ }
+
+ Version GetVersion() CXX11_OVERRIDE
+ {
+ return Version("Provides support for the +I channel mode", VF_VENDOR);
+ }
+};
+
+MODULE_INIT(ModuleInviteException)