Fixes world/Topic spam limiting (#16494)

This commit is contained in:
AffectedArc07
2021-08-11 15:37:37 -04:00
committed by GitHub
parent c91c6af382
commit ead4ca1324
4 changed files with 19 additions and 8 deletions
@@ -14,6 +14,8 @@
var/shutdown_shell_command = null
/// 2FA backend server host
var/_2fa_auth_host = null
/// List of IP addresses which bypass world topic rate limiting
var/list/topic_ip_ratelimit_bypass = list()
/datum/configuration_section/system_configuration/load_data(list/data)
// Use the load wrappers here. That way the default isnt made 'null' if you comment out the config line
@@ -24,3 +26,5 @@
CONFIG_LOAD_STR(medal_hub_password, data["medal_hub_password"])
CONFIG_LOAD_STR(shutdown_shell_command, data["shutdown_shell_command"])
CONFIG_LOAD_STR(_2fa_auth_host, data["_2fa_auth_host"])
CONFIG_LOAD_LIST(topic_ip_ratelimit_bypass, data["topic_ip_ratelimit_bypass"])
+8 -7
View File
@@ -85,15 +85,16 @@ GLOBAL_LIST_EMPTY(world_topic_handlers)
TGS_TOPIC
log_misc("WORLD/TOPIC: \"[T]\", from:[addr], master:[master], key:[key]")
// Handle spam prevention
if(!GLOB.world_topic_spam_prevention_handlers[address])
GLOB.world_topic_spam_prevention_handlers[address] = new /datum/world_topic_spam_prevention_handler
// Handle spam prevention, if their IP isnt in the whitelist
if(!(addr in GLOB.configuration.system.topic_ip_ratelimit_bypass))
if(!GLOB.world_topic_spam_prevention_handlers[addr])
GLOB.world_topic_spam_prevention_handlers[addr] = new /datum/world_topic_spam_prevention_handler(addr)
var/datum/world_topic_spam_prevention_handler/sph = GLOB.world_topic_spam_prevention_handlers[address]
var/datum/world_topic_spam_prevention_handler/sph = GLOB.world_topic_spam_prevention_handlers[addr]
// Lock the user out and cancel their topic if needed
if(sph.check_lockout())
return
// Lock the user out and cancel their topic if needed
if(sph.check_lockout())
return
var/list/input = params2list(T)
@@ -2,6 +2,8 @@
#define WORLD_TOPIC_LOCKOUT_TIME 1 MINUTES
/datum/world_topic_spam_prevention_handler
/// IP. Used purely for select purposes.
var/ip = null
/// Amount of strikes. [WORLD_TOPIC_STRIKES_THRESHOLD] strikes is a lockout of [WORLD_TOPIC_LOCKOUT_TIME]
var/strikes = 0
/// Time of last request
@@ -11,6 +13,9 @@
/// Unlock time
var/unlock_time = 0
/datum/world_topic_spam_prevention_handler/New(_ip)
ip = _ip
/**
* Lockout handler
*
+2 -1
View File
@@ -702,7 +702,8 @@ shutdown_on_reboot = false
#shutdown_shell_command = "taskkill /im dreamdaemon.exe /f"
# URL for the 2FA backend HTTP host. Do not use https:// or a trailing slash. Comment out to disable
#_2fa_auth_host = "http://127.0.0.1:8080"
# List of IP addresses to be ignored by the world/Topic rate limiting. Useful if you have other services
topic_ip_ratelimit_bypass = ["127.0.0.1"]
################################################################