]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add a silent option to <options:restrictbannedusers>.
authorPeter Powell <petpow@saberuk.com>
Tue, 10 Jul 2018 19:32:08 +0000 (20:32 +0100)
committerPeter Powell <petpow@saberuk.com>
Tue, 10 Jul 2018 20:01:35 +0000 (21:01 +0100)
This is useful when dealing with spambots that switch method when
they receive ERR_CANNOTSENDTOCHAN.

docs/conf/inspircd.conf.example
include/configreader.h
src/configreader.cpp
src/coremods/core_privmsg.cpp
src/coremods/core_user/cmd_nick.cpp

index b5671ee6b5683b9f3f8b7f8fb86d2ecf128cffe4..d06989551e4332536250ad0b580c8775ab6d004f 100644 (file)
 
           # restrictbannedusers: If this is set to yes, InspIRCd will not allow users
           # banned on a channel to change nickname or message channels they are
-          # banned on.
+          # banned on. This can also be set to silent to restrict the user but not
+          # notify them.
           restrictbannedusers="yes"
 
           # genericoper: Setting this value to yes makes all opers on this server
index be5c582b9da1b59e3c9101a09434185f4908fedb..a82420b4ed91e792b0f5fae4252e99c168d2ecd1 100644 (file)
@@ -210,6 +210,19 @@ class CoreExport ServerConfig
        void CrossCheckConnectBlocks(ServerConfig* current);
 
  public:
+       /** How to treat a user in a channel who is banned. */
+       enum BannedUserTreatment
+       {
+               /** Don't treat a banned user any different to normal. */
+               BUT_NORMAL,
+
+               /** Restrict the actions of a banned user. */
+               BUT_RESTRICT_SILENT,
+
+               /** Restrict the actions of a banned user and notify them of their treatment. */
+               BUT_RESTRICT_NOTIFY
+       };
+
        class ServerPaths
        {
         public:
@@ -330,10 +343,8 @@ class CoreExport ServerConfig
         */
        bool GenericOper;
 
-       /** If this value is true, banned users (+b, not extbans) will not be able to change nick
-        * if banned on any channel, nor to message them.
-        */
-       bool RestrictBannedUsers;
+       /** How to treat a user in a channel who is banned. */
+       BannedUserTreatment RestrictBannedUsers;
 
        /** The size of the read() buffer in the user
         * handling code, used to read data into a user's
index c9fa62510c5ca89f46008857bf312d585c878b79..b5d6b3ecb651a4500eed084aad781434ab01f06d 100644 (file)
@@ -434,7 +434,6 @@ void ServerConfig::Fill()
        HideServer = security->getString("hideserver", security->getString("hidewhois"));
        HideKillsServer = security->getString("hidekills");
        HideULineKills = security->getBool("hideulinekills");
-       RestrictBannedUsers = security->getBool("restrictbannedusers", true);
        GenericOper = security->getBool("genericoper");
        SyntaxHints = options->getBool("syntaxhints");
        CycleHostsFromUser = options->getBool("cyclehostsfromuser");
@@ -474,6 +473,16 @@ void ServerConfig::Fill()
        ReadXLine(this, "badhost", "host", ServerInstance->XLines->GetFactory("K"));
        ReadXLine(this, "exception", "host", ServerInstance->XLines->GetFactory("E"));
 
+       const std::string restrictbannedusers = options->getString("restrictbannedusers", "yes");
+       if (stdalgo::string::equalsci(restrictbannedusers, "no"))
+               RestrictBannedUsers = ServerConfig::BUT_NORMAL;
+       else if (stdalgo::string::equalsci(restrictbannedusers, "silent"))
+               RestrictBannedUsers = ServerConfig::BUT_RESTRICT_SILENT;
+       else if (stdalgo::string::equalsci(restrictbannedusers, "yes"))
+               RestrictBannedUsers =  ServerConfig::BUT_RESTRICT_NOTIFY;
+       else
+               throw CoreException(restrictbannedusers + " is an invalid <options:restrictbannedusers> value, at " + options->getTagLocation());
+
        DisabledUModes.reset();
        std::string modes = ConfValue("disabled")->getString("usermodes");
        for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p)
index 6c5b7557ecfaebf60aa7b6bbdd3760f2ff060b87..29756a4c28ec54ba5cd6b3db2f6b4f0bee9eb84c 100644 (file)
@@ -141,11 +141,12 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para
                                        return CMD_FAILURE;
                                }
 
-                               if (ServerInstance->Config->RestrictBannedUsers)
+                               if (ServerInstance->Config->RestrictBannedUsers != ServerConfig::BUT_NORMAL)
                                {
                                        if (chan->IsBanned(user))
                                        {
-                                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (you're banned)");
+                                               if (ServerInstance->Config->RestrictBannedUsers == ServerConfig::BUT_RESTRICT_NOTIFY)
+                                                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (you're banned)");
                                                return CMD_FAILURE;
                                        }
                                }
index 67215574151f9df3af0ba7395ac3f74bebc59972..80bfbe674fe083c5d3aa19bd382bdf9eff8a59cd 100644 (file)
@@ -70,15 +70,16 @@ CmdResult CommandNick::HandleLocal(const std::vector<std::string>& parameters, L
 
        // Disallow the nick change if <security:restrictbannedusers> is on and there is a ban matching this user in
        // one of the channels they are on
-       if (ServerInstance->Config->RestrictBannedUsers)
+       if (ServerInstance->Config->RestrictBannedUsers != ServerConfig::BUT_NORMAL)
        {
                for (User::ChanList::iterator i = user->chans.begin(); i != user->chans.end(); ++i)
                {
                        Channel* chan = (*i)->chan;
                        if (chan->GetPrefixValue(user) < VOICE_VALUE && chan->IsBanned(user))
                        {
-                               user->WriteNumeric(ERR_CANTCHANGENICK, InspIRCd::Format("Cannot change nickname while on %s (you're banned)",
-                                       chan->name.c_str()));
+                               if (ServerInstance->Config->RestrictBannedUsers == ServerConfig::BUT_RESTRICT_NOTIFY)
+                                       user->WriteNumeric(ERR_CANTCHANGENICK, InspIRCd::Format("Cannot change nickname while on %s (you're banned)",
+                                               chan->name.c_str()));
                                return CMD_FAILURE;
                        }
                }