diff options
| author | 2022-09-09 02:01:47 +0100 | |
|---|---|---|
| committer | 2022-09-09 02:16:13 +0100 | |
| commit | c56bea9d5fcbf239a63992eb9a141b43cb780184 (patch) | |
| tree | 230c371b4f0dbbe98ddd774d219daf8df5b0d4c5 | |
| parent | Default allow_empty_last_param to false. (diff) | |
Make internal penalty be specified in millisecs instead of seconds.
This removes the need to multiply it later.
23 files changed, 30 insertions, 30 deletions
diff --git a/include/ctables.h b/include/ctables.h index bfbf45912..e95a68d39 100644 --- a/include/ctables.h +++ b/include/ctables.h @@ -242,8 +242,8 @@ public: /** Whether the command will not be forwarded by the linking module even if it comes via ENCAP. */ bool force_manual_route = false; - /** The number of seconds worth of penalty that executing this command gives. */ - unsigned int Penalty = 1; + /** The number of milliseconds worth of penalty that executing this command gives. */ + unsigned int penalty = 1000; /** The number of times this command has been executed. */ unsigned long use_count = 0; diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 8a04ea72f..7f1ddf177 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -181,10 +181,10 @@ void CommandParser::ProcessCommand(LocalUser* user, std::string& command, Comman if (!user->HasPrivPermission("users/flood/no-throttle")) { // If it *doesn't* exist, give it a slightly heftier penalty than normal to deter flooding us crap - unsigned int penalty = (handler ? handler->Penalty * 1000 : 2000); + unsigned int penalty = handler ? handler->penalty : 2000; user->CommandFloodPenalty += penalty; - // Increase their penalty later if we fail and the command has 0 penalty by default (i.e. in Command::Penalty) to + // Increase their penalty later if we fail and the command has 0 penalty by default (i.e. in Command::penalty) to // throttle sending ERR_* from the command parser. If the command does have a non-zero penalty then this is not // needed because we've increased their penalty above. if (penalty == 0) diff --git a/src/coremods/core_channel/cmd_invite.cpp b/src/coremods/core_channel/cmd_invite.cpp index 350634a45..982688c23 100644 --- a/src/coremods/core_channel/cmd_invite.cpp +++ b/src/coremods/core_channel/cmd_invite.cpp @@ -49,7 +49,7 @@ CommandInvite::CommandInvite(Module* parent, Invite::APIImpl& invapiimpl) : Command(parent, "INVITE", 0, 0) , invapi(invapiimpl) { - Penalty = 4; + penalty = 4000; syntax = { "[<nick> <channel> [<time>]]" }; } diff --git a/src/coremods/core_channel/cmd_join.cpp b/src/coremods/core_channel/cmd_join.cpp index b08c2651b..71c5be667 100644 --- a/src/coremods/core_channel/cmd_join.cpp +++ b/src/coremods/core_channel/cmd_join.cpp @@ -29,8 +29,8 @@ CommandJoin::CommandJoin(Module* parent) : SplitCommand(parent, "JOIN", 1, 2) { + penalty = 2000; syntax = { "<channel>[,<channel>]+ [<key>[,<key>]+]" }; - Penalty = 2; } CmdResult CommandJoin::HandleLocal(LocalUser* user, const Params& parameters) diff --git a/src/coremods/core_channel/cmd_topic.cpp b/src/coremods/core_channel/cmd_topic.cpp index 9a3f46ab2..57e6ba4e1 100644 --- a/src/coremods/core_channel/cmd_topic.cpp +++ b/src/coremods/core_channel/cmd_topic.cpp @@ -47,8 +47,8 @@ CommandTopic::CommandTopic(Module* parent) , topiclockmode(parent, "topiclock") { allow_empty_last_param = true; + penalty = 2000; syntax = { "<channel> [:<topic>]" }; - Penalty = 2; } CmdResult CommandTopic::HandleLocal(LocalUser* user, const Params& parameters) diff --git a/src/coremods/core_info/cmd_admin.cpp b/src/coremods/core_info/cmd_admin.cpp index 823384519..51571fba5 100644 --- a/src/coremods/core_info/cmd_admin.cpp +++ b/src/coremods/core_info/cmd_admin.cpp @@ -38,7 +38,7 @@ enum CommandAdmin::CommandAdmin(Module* parent) : ServerTargetCommand(parent, "ADMIN") { - Penalty = 2; + penalty = 2000; syntax = { "[<servername>]" }; } diff --git a/src/coremods/core_info/cmd_commands.cpp b/src/coremods/core_info/cmd_commands.cpp index 7123247cc..9fd8194bb 100644 --- a/src/coremods/core_info/cmd_commands.cpp +++ b/src/coremods/core_info/cmd_commands.cpp @@ -37,7 +37,7 @@ enum CommandCommands::CommandCommands(Module* parent) : SplitCommand(parent, "COMMANDS") { - Penalty = 3; + penalty = 3000; } CmdResult CommandCommands::HandleLocal(LocalUser* user, const Params& parameters) @@ -77,7 +77,7 @@ CmdResult CommandCommands::HandleLocal(LocalUser* user, const Params& parameters numeric.push("*"); else numeric.push(command->max_params); - numeric.push(command->Penalty); + numeric.push(command->penalty); numerics.push_back(numeric); } diff --git a/src/coremods/core_info/cmd_info.cpp b/src/coremods/core_info/cmd_info.cpp index 3478f5fa4..5ce0bd28b 100644 --- a/src/coremods/core_info/cmd_info.cpp +++ b/src/coremods/core_info/cmd_info.cpp @@ -36,7 +36,7 @@ enum CommandInfo::CommandInfo(Module* parent) : SplitCommand(parent, "INFO") { - Penalty = 3; + penalty = 3000; } static const char* const lines[] = { diff --git a/src/coremods/core_info/cmd_modules.cpp b/src/coremods/core_info/cmd_modules.cpp index 827728c0b..05e6720cf 100644 --- a/src/coremods/core_info/cmd_modules.cpp +++ b/src/coremods/core_info/cmd_modules.cpp @@ -39,7 +39,7 @@ enum CommandModules::CommandModules(Module* parent) : ServerTargetCommand(parent, "MODULES") { - Penalty = 4; + penalty = 4000; syntax = { "[<servername>]" }; } diff --git a/src/coremods/core_list.cpp b/src/coremods/core_list.cpp index 2c6253c45..0ad74d55e 100644 --- a/src/coremods/core_list.cpp +++ b/src/coremods/core_list.cpp @@ -55,7 +55,7 @@ public: , secretmode(creator, "secret") , privatemode(creator, "private") { - Penalty = 5; + penalty = 5000; } CmdResult Handle(User* user, const Params& parameters) override; diff --git a/src/coremods/core_oper/cmd_rehash.cpp b/src/coremods/core_oper/cmd_rehash.cpp index b3684f0c7..c19281f7f 100644 --- a/src/coremods/core_oper/cmd_rehash.cpp +++ b/src/coremods/core_oper/cmd_rehash.cpp @@ -40,7 +40,7 @@ CommandRehash::CommandRehash(Module* parent) : Command(parent, "REHASH", 0) { access_needed = CmdAccess::OPERATOR; - Penalty = 2; + penalty = 2000; syntax = { "[<servermask>]" }; } diff --git a/src/coremods/core_user/cmd_nick.cpp b/src/coremods/core_user/cmd_nick.cpp index 46adea51d..5c1c799cb 100644 --- a/src/coremods/core_user/cmd_nick.cpp +++ b/src/coremods/core_user/cmd_nick.cpp @@ -38,9 +38,9 @@ CommandNick::CommandNick(Module* parent) : SplitCommand(parent, "NICK", 1) { allow_empty_last_param = true; - works_before_reg = true; + penalty = 0; syntax = { "<newnick>" }; - Penalty = 0; + works_before_reg = true; } /** Handle nick changes from users. diff --git a/src/coremods/core_user/cmd_part.cpp b/src/coremods/core_user/cmd_part.cpp index 1db5a6f37..121d7169f 100644 --- a/src/coremods/core_user/cmd_part.cpp +++ b/src/coremods/core_user/cmd_part.cpp @@ -34,7 +34,7 @@ CommandPart::CommandPart(Module* parent) : Command(parent, "PART", 1, 2) { allow_empty_last_param = true; - Penalty = 5; + penalty = 5000; syntax = { "<channel>[,<channel>]+ [:<reason>]" }; } diff --git a/src/coremods/core_user/cmd_user.cpp b/src/coremods/core_user/cmd_user.cpp index 6018bf964..dc641a267 100644 --- a/src/coremods/core_user/cmd_user.cpp +++ b/src/coremods/core_user/cmd_user.cpp @@ -36,9 +36,9 @@ enum CommandUser::CommandUser(Module* parent) : SplitCommand(parent, "USER", 4, 4) { - works_before_reg = true; - Penalty = 0; + penalty = 0; syntax = { "<username> <unused> <unused> :<realname>" }; + works_before_reg = true; } CmdResult CommandUser::HandleLocal(LocalUser* user, const Params& parameters) diff --git a/src/coremods/core_user/core_user.cpp b/src/coremods/core_user/core_user.cpp index 24ba7c666..57591a3f4 100644 --- a/src/coremods/core_user/core_user.cpp +++ b/src/coremods/core_user/core_user.cpp @@ -36,9 +36,9 @@ public: CommandPass(Module* parent) : SplitCommand(parent, "PASS", 1, 1) { - works_before_reg = true; - Penalty = 0; + penalty = 0; syntax = { "<password>" }; + works_before_reg = true; } CmdResult HandleLocal(LocalUser* user, const Params& parameters) override @@ -88,7 +88,7 @@ public: CommandPong(Module* parent) : Command(parent, "PONG", 1) { - Penalty = 0; + penalty = 0; syntax = { "<cookie> [<servername>]" }; } diff --git a/src/coremods/core_whois.cpp b/src/coremods/core_whois.cpp index ac23db492..fcbfb7ce7 100644 --- a/src/coremods/core_whois.cpp +++ b/src/coremods/core_whois.cpp @@ -94,7 +94,7 @@ public: , evprov(parent, "event/whois") , lineevprov(parent, "event/whoisline") { - Penalty = 2; + penalty = 2000; syntax = { "[<servername>] <nick>[,<nick>]+" }; } diff --git a/src/coremods/core_whowas.cpp b/src/coremods/core_whowas.cpp index ce32b11bd..de10ddee3 100644 --- a/src/coremods/core_whowas.cpp +++ b/src/coremods/core_whowas.cpp @@ -188,8 +188,8 @@ public: CommandWhowas::CommandWhowas( Module* parent) : Command(parent, "WHOWAS", 1) { + penalty = 2000; syntax = { "<nick> [<count>]" }; - Penalty = 2; } CmdResult CommandWhowas::Handle(User* user, const Params& parameters) diff --git a/src/modules/m_cycle.cpp b/src/modules/m_cycle.cpp index 47966ccce..0b75f5d0c 100644 --- a/src/modules/m_cycle.cpp +++ b/src/modules/m_cycle.cpp @@ -36,7 +36,7 @@ public: CommandCycle(Module* Creator) : SplitCommand(Creator, "CYCLE", 1) { - Penalty = 3; + penalty = 3000; syntax = { "<channel> [:<reason>]" }; } diff --git a/src/modules/m_gateway.cpp b/src/modules/m_gateway.cpp index dbdc0cbf0..6ca99fbb2 100644 --- a/src/modules/m_gateway.cpp +++ b/src/modules/m_gateway.cpp @@ -133,7 +133,7 @@ public: CommandHexIP(Module* Creator) : SplitCommand(Creator, "HEXIP", 1) { - Penalty = 2; + penalty = 2000; syntax = { "<hex-ip|raw-ip>" }; } diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp index 7d11fee7d..836164268 100644 --- a/src/modules/m_knock.cpp +++ b/src/modules/m_knock.cpp @@ -75,8 +75,8 @@ public: , inviteonlymode(Creator, "inviteonly") , inviteapi(Creator) { + penalty = 5000; syntax = { "<channel> :<reason>" }; - Penalty = 5; } CmdResult Handle(User* user, const Params& parameters) override diff --git a/src/modules/m_monitor.cpp b/src/modules/m_monitor.cpp index a97d0fefa..b6a0d3022 100644 --- a/src/modules/m_monitor.cpp +++ b/src/modules/m_monitor.cpp @@ -310,7 +310,7 @@ public: : SplitCommand(mod, "MONITOR", 1) , manager(managerref) { - Penalty = 2; + penalty = 2000; syntax = { "C", "L", "S", "(+|-) <nick>[,<nick>]+" }; } diff --git a/src/modules/m_password_hash.cpp b/src/modules/m_password_hash.cpp index 517183e1a..4aa384192 100644 --- a/src/modules/m_password_hash.cpp +++ b/src/modules/m_password_hash.cpp @@ -33,8 +33,8 @@ class CommandMkpasswd final public: CommandMkpasswd(Module* Creator) : Command(Creator, "MKPASSWD", 2) { + penalty = 5000; syntax = { "<hashtype> <plaintext>" }; - Penalty = 5; } CmdResult Handle(User* user, const Params& parameters) override diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp index 1df272e41..bdc6f1729 100644 --- a/src/modules/m_spanningtree/override_map.cpp +++ b/src/modules/m_spanningtree/override_map.cpp @@ -37,7 +37,7 @@ CommandMap::CommandMap(Module* Creator) : Command(Creator, "MAP", 0, 1) { - Penalty = 2; + penalty = 2000; } static inline bool IsHidden(User* user, TreeServer* server) |
