From 83bcc83a56a235f5c4e479ff47713f467640a4eb Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 12 Jan 2015 14:19:58 +0100 Subject: Increase penalty for some core commands --- src/commands/cmd_motd.cpp | 6 ++++++ src/commands/cmd_pass.cpp | 1 + src/commands/cmd_ping.cpp | 2 +- src/commands/cmd_pong.cpp | 11 +++++++++-- src/commands/cmd_rules.cpp | 6 ++++++ src/commands/cmd_stats.cpp | 6 ++++++ src/commands/cmd_user.cpp | 1 + 7 files changed, 30 insertions(+), 3 deletions(-) (limited to 'src/commands') diff --git a/src/commands/cmd_motd.cpp b/src/commands/cmd_motd.cpp index 869a9c353..9ed5ff188 100644 --- a/src/commands/cmd_motd.cpp +++ b/src/commands/cmd_motd.cpp @@ -51,7 +51,13 @@ class CommandMotd : public Command CmdResult CommandMotd::Handle (const std::vector& 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)) diff --git a/src/commands/cmd_pass.cpp b/src/commands/cmd_pass.cpp index f082a4ce8..9fc758874 100644 --- a/src/commands/cmd_pass.cpp +++ b/src/commands/cmd_pass.cpp @@ -46,6 +46,7 @@ CmdResult CommandPass::HandleLocal(const std::vector& 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; } diff --git a/src/commands/cmd_ping.cpp b/src/commands/cmd_ping.cpp index 3ccadd929..dd14b52c8 100644 --- a/src/commands/cmd_ping.cpp +++ b/src/commands/cmd_ping.cpp @@ -30,7 +30,7 @@ class CommandPing : public Command public: /** Constructor for ping. */ - CommandPing ( Module* parent) : Command(parent,"PING", 1, 2) { Penalty = 0; syntax = " [:]"; } + CommandPing ( Module* parent) : Command(parent,"PING", 1, 2) { syntax = " [:]"; } /** Handle command. * @param parameters The parameters to the comamnd * @param pcnt The number of parameters passed to teh command diff --git a/src/commands/cmd_pong.cpp b/src/commands/cmd_pong.cpp index 825168de7..3b6f17f3b 100644 --- a/src/commands/cmd_pong.cpp +++ b/src/commands/cmd_pong.cpp @@ -43,8 +43,15 @@ class CommandPong : public Command CmdResult CommandPong::Handle (const std::vector&, 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; } diff --git a/src/commands/cmd_rules.cpp b/src/commands/cmd_rules.cpp index 17de9f3f2..7aacf8c31 100644 --- a/src/commands/cmd_rules.cpp +++ b/src/commands/cmd_rules.cpp @@ -49,7 +49,13 @@ class CommandRules : public Command CmdResult CommandRules::Handle (const std::vector& 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)) diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp index 60bb5b30e..d547635ed 100644 --- a/src/commands/cmd_stats.cpp +++ b/src/commands/cmd_stats.cpp @@ -420,7 +420,13 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results) CmdResult CommandStats::Handle (const std::vector& parameters, User *user) { if (parameters.size() > 1 && parameters[1] != ServerInstance->Config->ServerName) + { + // Give extra penalty if a non-oper does /STATS + 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); diff --git a/src/commands/cmd_user.cpp b/src/commands/cmd_user.cpp index 305d0847f..09e1e3319 100644 --- a/src/commands/cmd_user.cpp +++ b/src/commands/cmd_user.cpp @@ -68,6 +68,7 @@ CmdResult CommandUser::HandleLocal(const std::vector& parameters, L } else { + user->CommandFloodPenalty += 1000; user->WriteNumeric(462, "%s :You may not reregister", user->nick.c_str()); return CMD_FAILURE; } -- cgit v1.2.3