From b86e0b5fa71372c35eea9d48239feaa9a11a5854 Mon Sep 17 00:00:00 2001 From: oranges Date: Thu, 2 Jan 2020 21:39:11 +0000 Subject: [PATCH] Readd cooldowns on the world topic Thanks to whomever removed these, you're a real star --- code/game/world.dm | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/code/game/world.dm b/code/game/world.dm index 3746cad1d4a5d25..ca1df54588ae1d6 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -1,4 +1,6 @@ #define RESTART_COUNTER_PATH "data/round_counter.txt" +#define MAX_TOPIC_LEN 100 +#define TOPIC_BANNED 1 GLOBAL_VAR(restart_counter) @@ -164,10 +166,30 @@ GLOBAL_VAR(restart_counter) log_runtime(GLOB.revdata.get_log_message()) /world/Topic(T, addr, master, key) - TGS_TOPIC //redirect to server tools if necessary - + var/static/list/bannedsourceaddrs = list() + var/static/list/lasttimeaddr = list() var/static/list/topic_handlers = TopicHandlers() + //LEAVE THIS COOLDOWN HANDLING IN PLACE, OR SO HELP ME I WILL MAKE YOU SUFFER + if (addr in bannedsourceaddrs) + return + + if (T.length >= MAX_TOPIC_LEN) + log_admin("[addr] banned from topic calls for a round for too long status message") + bannedsourceaddrs[addr] = TOPIC_BANNED + return + if (addr in lasttimeaddr) + var/lasttime = lasttimeaddr[addr] + if(world.time < (lasttime + 2 SECONDS)) + log_admin("[addr] banned from topic calls for a round for too frequent messages") + bannedsourceaddrs[addr] = TOPIC_BANNED + return + + lasttimeaddr[addr] = world.time + + + TGS_TOPIC //redirect to server tools if necessary + var/list/input = params2list(T) var/datum/world_topic/handler for(var/I in topic_handlers)