summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-30 18:48:41 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-30 18:48:41 +0000
commit2c1dd9be2be86546e6dc1231b5df80af1ec1b23a (patch)
tree3e748cced302c9fa68c685815419984d7fbfa9e1
parentd9147559a3212ff9e61f9fed63ba361505ad519f (diff)
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
-rw-r--r--docs/inspircd.conf.example7
-rw-r--r--src/modules/m_hidechans.cpp118
2 files changed, 124 insertions, 1 deletions
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
@@ -1039,9 +1039,14 @@
#<helpop file="helpop.conf">
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
+# HIDECHANS module: Allows opers to hide their channels list from non-
+# opers by setting user mode +I on themselves.
+# <module name="m_hidechans.so">
+
+#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# HIDEOPER module: Allows opers to hide their oper status from non-
# opers by setting user mode +H on themselves.
-# <module name="m_hideoper.h">
+# <module name="m_hideoper.so">
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# 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:
+ * <brain@chatspike.net>
+ * <Craig@chatspike.net>
+ *
+ * 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 &parameter, 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;
+}