]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Replace strip/blockcolor tags with <options:exemptchanops>, sexy string of modes...
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 13 May 2007 22:10:57 +0000 (22:10 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 13 May 2007 22:10:57 +0000 (22:10 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7018 e03df62e-2008-0410-955e-edbf42e46eb7

docs/inspircd.conf.example
include/configreader.h
src/configreader.cpp
src/modules/m_blockcolor.cpp
src/modules/m_stripcolor.cpp

index 1379a077b340ed14f4217dfd8d3327a232bd3599..e37088f10d3573d25885a7034c6d923a641ac029 100644 (file)
 #                  This can be useful for finding servers which are   #
 #                  at risk of pinging out due to network issues.      #
 #                                                                     #
+#  exemptchanops - This option allows channel operators to be exempted#
+#                  from certain channel modes.                        #
+#                  Supported modes are +Sc. Defaults to Sc.           #
 
 <options prefixquit="Quit: "
          loglevel="default"
          hidemodes="eI"
          quietbursts="yes"
          pingwarning="15"
-         allowhalfop="yes">
+         allowhalfop="yes"
+        exemptchanops="Sc">
 
 #-#-#-#-#-#-#-#-#-#-#-#-#-#- TIME SYNC OPTIONS -#-#-#-#-#-#-#-#-#-#-#-#
 # Time sychronization options for m_spanningtree linking.             #
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
 # Block colour module: Blocking colour-coded messages with cmode +c
 #<module name="m_blockcolor.so">
-#
-# Optionally, you can allow channel ops to bypass filtering. Defaults to no.
-# <blockcolor allowchanops="no">
 
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
 # Botmode module: Adds the user mode +B
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
 # Strip colour module: Adds the channel mode +S
 #<module name="m_stripcolor.so">
-#
-# Optionally, you can allow channel ops to bypass filtering. Defaults to no.
-# <stripcolor allowchanops="no">
 
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
 # SILENCE module: Adds support for /SILENCE
index db4c6d3d50b7b54fd17e08fe4756785c7de6ae72..772de2177d06307996b5f3e38c37e0a8e3a2be36 100644 (file)
 #ifndef INSPIRCD_CONFIGREADER
 #define INSPIRCD_CONFIGREADER
 
+/* handy defines */
+
+/** Determines if a channel op is exempt from given mode m,
+ * in config of server instance s. 
+ */
+#define CHANOPS_EXEMPT(s, m) (s->Config->ExemptChanOps[(unsigned char)m])
+
 #include <sstream>
 #include <string>
 #include <vector>
@@ -355,6 +362,11 @@ class ServerConfig : public Extensible
         */
        bool HideModeLists[256];
 
+       /** If this is set to true, then channel operators
+        * are exempt from this channel mode. Used for +Sc etc.
+        */
+       bool ExemptChanOps[256];
+
        /** The number of seconds the DNS subsystem
         * will wait before timing out any request.
         */
index 1bc530b9b3c21f857bbe32fc8f104b7677c146de..6e728c31117a0db2ef1796a4b47a759d6424afdd 100644 (file)
@@ -341,6 +341,14 @@ bool ValidateModeLists(ServerConfig* conf, const char* tag, const char* value, V
        return true;
 }
 
+bool ValidateExemptChanOps(ServerConfig* conf, const char* tag, const char* value, ValueItem &data)
+{
+       memset(conf->ExemptChanOps, 0, 256);
+       for (const unsigned char* x = (const unsigned char*)data.GetString(); *x; ++x)
+               conf->ExemptChanOps[*x] = true;
+       return true;
+}
+
 bool ValidateWhoWas(ServerConfig* conf, const char* tag, const char* value, ValueItem &data)
 {
        conf->WhoWasMaxKeep = conf->GetInstance()->Duration(data.GetString());
@@ -567,6 +575,7 @@ void ServerConfig::Read(bool bail, userrec* user)
        static char debug[MAXBUF];      /* Temporary buffer for debugging value */
        static char maxkeep[MAXBUF];    /* Temporary buffer for WhoWasMaxKeep value */
        static char hidemodes[MAXBUF];  /* Modes to not allow listing from users below halfop */
+       static char exemptchanops[MAXBUF];      /* Exempt channel ops from these modes */
        int rem = 0, add = 0;           /* Number of modules added, number of modules removed */
        std::ostringstream errstr;      /* String stream containing the error output */
 
@@ -613,6 +622,7 @@ void ServerConfig::Read(bool bail, userrec* user)
                {"options",     "announceinvites", "1",                 new ValueContainerBool (&this->AnnounceInvites),        DT_BOOLEAN, NoValidation},
                {"options",     "hostintopic",  "1",                    new ValueContainerBool (&this->FullHostInTopic),        DT_BOOLEAN, NoValidation},
                {"options",     "hidemodes",    "",                     new ValueContainerChar (hidemodes),                     DT_CHARPTR, ValidateModeLists},
+               {"options",     "exemptchanops","",                     new ValueContainerChar (exemptchanops),                 DT_CHARPTR, ValidateExemptChanOps},
                {"pid",         "file",         "",                     new ValueContainerChar (this->PID),                     DT_CHARPTR, NoValidation},
                {"whowas",      "groupsize",    "10",                   new ValueContainerInt  (&this->WhoWasGroupSize),        DT_INTEGER, NoValidation},
                {"whowas",      "maxgroups",    "10240",                new ValueContainerInt  (&this->WhoWasMaxGroups),        DT_INTEGER, NoValidation},
index a40d4ebd3f11439d8c98de462e5fd8648d98afd7..219637fb958c6a0198f521e37f4dff47e3ceef42 100644 (file)
@@ -61,23 +61,14 @@ class ModuleBlockColour : public Module
                bc = new BlockColor(ServerInstance);
                if (!ServerInstance->AddMode(bc, 'c'))
                        throw ModuleException("Could not add new modes!");
-
-               OnRehash(NULL, "");
        }
 
        void Implements(char* List)
        {
-               List[I_OnRehash] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
+               List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
        }
 
 
-       virtual void OnRehash(userrec* user, const std::string &parameter)
-       {
-               ConfigReader Conf(ServerInstance);
-
-               AllowChanOps = Conf.ReadFlag("blockcolor", "allowchanops", 0);
-       }
-
        virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
        {
                if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
@@ -86,7 +77,7 @@ class ModuleBlockColour : public Module
                        
                        if(c->IsModeSet('c'))
                        {
-                               if (!AllowChanOps || AllowChanOps && c->GetStatus(user) != STATUS_OP)
+                               if (!CHANOPS_EXEMPT(ServerInstance, 'c') || CHANOPS_EXEMPT(ServerInstance, 'c') && c->GetStatus(user) != STATUS_OP)
                                {
                                        for (std::string::iterator i = text.begin(); i != text.end(); i++)
                                        {
index e2f7482a9e3913a51742be8038fce507104fe9e0..76bc56ef5d6df97e3ad47aa8e7703bbbcf62c5c9 100644 (file)
@@ -92,8 +92,6 @@ class ModuleStripColor : public Module
  public:
        ModuleStripColor(InspIRCd* Me) : Module::Module(Me)
        {
-               OnRehash(NULL, "");
-
                usc = new UserStripColor(ServerInstance);
                csc = new ChannelStripColor(ServerInstance);
 
@@ -103,7 +101,7 @@ class ModuleStripColor : public Module
 
        void Implements(char* List)
        {
-               List[I_OnRehash] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
+               List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
        }
 
        virtual ~ModuleStripColor()
@@ -164,13 +162,6 @@ class ModuleStripColor : public Module
                }
        }
 
-       virtual void OnRehash(userrec* user, const std::string &parameter)
-       {
-               ConfigReader Conf(ServerInstance);
-
-               AllowChanOps = Conf.ReadFlag("stripcolor", "allowchanops", 0);
-       }
-       
        virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
        {
                if (!IS_LOCAL(user))
@@ -188,7 +179,7 @@ class ModuleStripColor : public Module
 
                        // check if we allow ops to bypass filtering, if we do, check if they're opped accordingly.
                        // note: short circut logic here, don't wreck it. -- w00t
-                       if (!AllowChanOps || AllowChanOps && t->GetStatus(user) != STATUS_OP)
+                       if (!CHANOPS_EXEMPT(ServerInstance, 'S') || CHANOPS_EXEMPT(ServerInstance, 'S') && t->GetStatus(user) != STATUS_OP)
                                active = t->IsModeSet('S');
                }