-/* +------------------------------------+\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
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
+ *
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#include "inspircd.h"
+#include "u_listmode.h"
+
+/* $ModDesc: Provides support for the +I channel mode */
+/* $ModDep: ../../include/u_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
+{
+ InviteException ie;
+public:
+ ModuleInviteException() : ie(this)
+ {
+ if (!ServerInstance->Modes->AddMode(&ie))
+ throw ModuleException("Could not add new modes!");
+
+ ie.DoImplements(this);
+ Implementation eventlist[] = { I_On005Numeric, I_OnCheckInvite };
+ ServerInstance->Modules->Attach(eventlist, this, 2);
+ }
+
+ void On005Numeric(std::string &output)
+ {
+ output.append(" INVEX=I");
+ }
+
+ ModResult OnCheckInvite(User* user, Channel* chan)
+ {
+ if(chan != NULL)
+ {
+ modelist* list = ie.extItem.get(chan);
+ if (list)
+ {
+ for (modelist::iterator it = list->begin(); it != list->end(); it++)
+ {
+ if (chan->CheckBan(user, it->mask))
+ {
+ return MOD_RES_ALLOW;
+ }
+ }
+ }
+ }
+
+ return MOD_RES_PASSTHRU;
+ }
+
+ void OnCleanup(int target_type, void* item)
+ {
+ ie.DoCleanup(target_type, item);
+ }
+
+ void OnSyncChannel(Channel* chan, Module* proto, void* opaque)
+ {
+ ie.DoSyncChannel(chan, proto, opaque);
+ }
+
+ void OnRehash(User* user)
+ {
+ ie.DoRehash();
+ }
+
+ Version GetVersion()
+ {
+ return Version("Provides support for the +I channel mode", VF_VENDOR | VF_COMMON);
+ }
+};
+
+MODULE_INIT(ModuleInviteException)