From 3a8e096657db53979babde64eff09e59cac40fa5 Mon Sep 17 00:00:00 2001 From: Edo Date: Wed, 26 Apr 2023 10:36:34 +0100 Subject: [PATCH] rcon: use netadr_t as key --- src/client/component/rcon.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/client/component/rcon.cpp b/src/client/component/rcon.cpp index 05039c00..fad179d3 100644 --- a/src/client/component/rcon.cpp +++ b/src/client/component/rcon.cpp @@ -16,7 +16,7 @@ namespace rcon { const game::dvar_t* rcon_timeout; - std::unordered_map rate_limit_map; + std::unordered_map rate_limit_map; std::optional get_and_validate_rcon_command(const std::string& data) { @@ -57,20 +57,19 @@ namespace rcon bool rate_limit_check(const game::netadr_t& address, const int time) { - const auto hash = std::hash()(address); - if (!rate_limit_map.contains(hash)) + if (!rate_limit_map.contains(address)) { - rate_limit_map[hash] = 0; + rate_limit_map[address] = 0; } - const auto last_time = rate_limit_map[hash]; + const auto last_time = rate_limit_map[address]; if (last_time && (time - last_time) < rcon_timeout->current.value.integer) { return false; // Flooding } - rate_limit_map[hash] = time; + rate_limit_map[address] = time; return true; }