]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Increase penalty for some core commands
authorAttila Molnar <attilamolnar@hush.com>
Mon, 12 Jan 2015 13:19:58 +0000 (14:19 +0100)
committerAttila Molnar <attilamolnar@hush.com>
Mon, 12 Jan 2015 13:19:58 +0000 (14:19 +0100)
src/commands/cmd_motd.cpp
src/commands/cmd_pass.cpp
src/commands/cmd_ping.cpp
src/commands/cmd_pong.cpp
src/commands/cmd_rules.cpp
src/commands/cmd_stats.cpp
src/commands/cmd_user.cpp

index 869a9c3538652af4775da4791b742b4d325a26bf..9ed5ff188079fa1a86e3bc4737e128470c471425 100644 (file)
@@ -51,7 +51,13 @@ class CommandMotd : public Command
 CmdResult CommandMotd::Handle (const std::vector<std::string>& parameters, User *user)
 {
        if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName)
+       {
+               // Give extra penalty if a non-oper queries the /MOTD of a remote server
+               LocalUser* localuser = IS_LOCAL(user);
+               if ((localuser) && (!IS_OPER(user)))
+                       localuser->CommandFloodPenalty += 2000;
                return CMD_SUCCESS;
+       }
 
        ConfigTag* tag = ServerInstance->Config->EmptyTag;
        if (IS_LOCAL(user))
index f082a4ce8b53d4cc464ce0ecebeaa7cd68bc3d8a..9fc7588744ad8e73f0a20f4179d0587cf82f619c 100644 (file)
@@ -46,6 +46,7 @@ CmdResult CommandPass::HandleLocal(const std::vector<std::string>& parameters, L
        // Check to make sure they haven't registered -- Fix by FCS
        if (user->registered == REG_ALL)
        {
+               user->CommandFloodPenalty += 1000;
                user->WriteNumeric(ERR_ALREADYREGISTERED, "%s :You may not reregister",user->nick.c_str());
                return CMD_FAILURE;
        }
index 3ccadd929d1c50200c411b53351d9067b76455a6..dd14b52c82681f665c1086cf9b2121dd4d0dc873 100644 (file)
@@ -30,7 +30,7 @@ class CommandPing : public Command
  public:
        /** Constructor for ping.
         */
-       CommandPing ( Module* parent) : Command(parent,"PING", 1, 2) { Penalty = 0; syntax = "<servername> [:<servername>]"; }
+       CommandPing ( Module* parent) : Command(parent,"PING", 1, 2) { syntax = "<servername> [:<servername>]"; }
        /** Handle command.
         * @param parameters The parameters to the comamnd
         * @param pcnt The number of parameters passed to teh command
index 825168de7773e656e43f1d2fe67df0cd71696d3e..3b6f17f3bd441573ee056ca280502c03b2030677 100644 (file)
@@ -43,8 +43,15 @@ class CommandPong : public Command
 CmdResult CommandPong::Handle (const std::vector<std::string>&, User *user)
 {
        // set the user as alive so they survive to next ping
-       if (IS_LOCAL(user))
-               IS_LOCAL(user)->lastping = 1;
+       LocalUser* localuser = IS_LOCAL(user);
+       if (localuser)
+       {
+               // Increase penalty unless we've sent a PING and this is the reply
+               if (localuser->lastping)
+                       localuser->CommandFloodPenalty += 1000;
+               else
+                       localuser->lastping = 1;
+       }
        return CMD_SUCCESS;
 }
 
index 17de9f3f2235ffcf7a6333383861702185158240..7aacf8c31262be7cf17f1e204a6e7ceda6e2ea99 100644 (file)
@@ -49,7 +49,13 @@ class CommandRules : public Command
 CmdResult CommandRules::Handle (const std::vector<std::string>& parameters, User *user)
 {
        if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName)
+       {
+               // Give extra penalty if a non-oper queries the /RULES of a remote server
+               LocalUser* localuser = IS_LOCAL(user);
+               if ((localuser) && (!IS_OPER(user)))
+                       localuser->CommandFloodPenalty += 2000;
                return CMD_SUCCESS;
+       }
 
        ConfigTag* tag = ServerInstance->Config->EmptyTag;
        if (IS_LOCAL(user))
index 60bb5b30ee7ae3a586276fd0834178bbdbf546b5..d547635ed37968e1931e520fad687eba0de64a3b 100644 (file)
@@ -420,7 +420,13 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results)
 CmdResult CommandStats::Handle (const std::vector<std::string>& parameters, User *user)
 {
        if (parameters.size() > 1 && parameters[1] != ServerInstance->Config->ServerName)
+       {
+               // Give extra penalty if a non-oper does /STATS <remoteserver>
+               LocalUser* localuser = IS_LOCAL(user);
+               if ((localuser) && (!IS_OPER(user)))
+                       localuser->CommandFloodPenalty += 2000;
                return CMD_SUCCESS;
+       }
        string_list values;
        char search = parameters[0][0];
        DoStats(search, user, values);
index 305d0847f2e598bf0ab696f2fb5e7b43687bfdea..09e1e3319475e204caf67c4254c456ac825028af 100644 (file)
@@ -68,6 +68,7 @@ CmdResult CommandUser::HandleLocal(const std::vector<std::string>& parameters, L
        }
        else
        {
+               user->CommandFloodPenalty += 1000;
                user->WriteNumeric(462, "%s :You may not reregister", user->nick.c_str());
                return CMD_FAILURE;
        }