From 2c1dd9be2be86546e6dc1231b5df80af1ec1b23a Mon Sep 17 00:00:00 2001 From: w00t Date: Mon, 30 Oct 2006 18:48:41 +0000 Subject: Add m_hidechans: Adds usermode +I to hide an oper's channels from non-opers. Also, we don't want to load a .h in the config, Brain :p git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5583 e03df62e-2008-0410-955e-edbf42e46eb7 --- docs/inspircd.conf.example | 7 ++- src/modules/m_hidechans.cpp | 118 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 src/modules/m_hidechans.cpp diff --git a/docs/inspircd.conf.example b/docs/inspircd.conf.example index 6d86344c0..9a05f43db 100644 --- a/docs/inspircd.conf.example +++ b/docs/inspircd.conf.example @@ -1038,10 +1038,15 @@ # # # +#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# +# HIDECHANS module: Allows opers to hide their channels list from non- +# opers by setting user mode +I on themselves. +# + #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # HIDEOPER module: Allows opers to hide their oper status from non- # opers by setting user mode +H on themselves. -# +# #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Hostchange module: Allows a different style of cloaking diff --git a/src/modules/m_hidechans.cpp b/src/modules/m_hidechans.cpp new file mode 100644 index 000000000..68ce664be --- /dev/null +++ b/src/modules/m_hidechans.cpp @@ -0,0 +1,118 @@ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. + * E-mail: + * + * + * + * Written by Craig Edwards, Craig McLure, and others. + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#include "users.h" +#include "channels.h" +#include "modules.h" +#include "inspircd.h" + +/* $ModDesc: Provides support for hiding oper status with user mode +I */ + +/** Handles user mode +I + */ +class HideChans : public ModeHandler +{ + public: + HideChans(InspIRCd* Instance) : ModeHandler(Instance, 'I', 0, 0, false, MODETYPE_USER, true) { } + + ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) + { + /* Only opers can change other users modes */ + if ((source != dest) && (!*source->oper)) + return MODEACTION_DENY; + + if (adding) + { + if (!dest->IsModeSet('I')) + { + dest->SetMode('I',true); + return MODEACTION_ALLOW; + } + } + else + { + if (dest->IsModeSet('I')) + { + dest->SetMode('I',false); + return MODEACTION_ALLOW; + } + } + + return MODEACTION_DENY; + } +}; + +class ModuleHideChans : public Module +{ + + HideChans* hm; + public: + ModuleHideChans(InspIRCd* Me) + : Module::Module(Me) + { + + hm = new HideChans(ServerInstance); + ServerInstance->AddMode(hm, 'I'); + } + + void Implements(char* List) + { + List[I_OnWhoisLine] = 1; + } + + virtual ~ModuleHideChans() + { + ServerInstance->Modes->DelMode(hm); + DELETE(hm); + } + + virtual Version GetVersion() + { + return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION); + } + + int OnWhoisLine(userrec* user, userrec* dest, int &numeric, std::string &text) + { + /* Dont display channels if they have +I set and the + * person doing the WHOIS is not an oper + */ + return ((!*user->oper) && (numeric == 319) && dest->IsModeSet('I')); + } +}; + +class ModuleHideChansFactory : public ModuleFactory +{ + public: + ModuleHideChansFactory() + { + } + + ~ModuleHideChansFactory() + { + } + + virtual Module * CreateModule(InspIRCd* Me) + { + return new ModuleHideChans(Me); + } + +}; + + +extern "C" void * init_module( void ) +{ + return new ModuleHideChansFactory; +} -- cgit v1.2.3