diff --git a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm index c194e578c9..5c54843df2 100644 --- a/code/__DEFINES/subsystems.dm +++ b/code/__DEFINES/subsystems.dm @@ -47,6 +47,7 @@ // Subsystems shutdown in the reverse of the order they initialize in // The numbers just define the ordering, they are meaningless otherwise. +#define INIT_ORDER_FAIL2TOPIC 22 #define INIT_ORDER_TITLE 20 #define INIT_ORDER_GARBAGE 19 #define INIT_ORDER_DBCORE 18 diff --git a/code/__HELPERS/_logging.dm b/code/__HELPERS/_logging.dm index 241e9b906e..4dd590d9a1 100644 --- a/code/__HELPERS/_logging.dm +++ b/code/__HELPERS/_logging.dm @@ -139,7 +139,7 @@ if (CONFIG_GET(flag/log_job_debug)) WRITE_LOG(GLOB.world_job_debug_log, "JOB: [text]") -/proc/log_ss(subsystem, text) +/proc/log_subsystem(subsystem, text) WRITE_LOG(GLOB.subsystem_log, "[subsystem]: [text]") /* Log to both DD and the logfile. */ diff --git a/code/_globalvars/logging.dm b/code/_globalvars/logging.dm index 5ca3513e66..01d5051dba 100644 --- a/code/_globalvars/logging.dm +++ b/code/_globalvars/logging.dm @@ -30,6 +30,8 @@ GLOBAL_VAR(world_virus_log) GLOBAL_PROTECT(world_virus_log) GLOBAL_VAR(world_map_error_log) GLOBAL_PROTECT(world_map_error_log) +GLOBAL_VAR(subsystem_log) +GLOBAL_PROTECT(subsystem_log) GLOBAL_LIST_EMPTY(bombers) GLOBAL_PROTECT(bombers) diff --git a/code/controllers/configuration/entries/fail2topic.dm b/code/controllers/configuration/entries/fail2topic.dm index 665a55dd0f..7e5bfd7ee8 100644 --- a/code/controllers/configuration/entries/fail2topic.dm +++ b/code/controllers/configuration/entries/fail2topic.dm @@ -13,3 +13,7 @@ /datum/config_entry/number/topic_max_size config_entry_value = 8192 + +/datum/config_entry/keyed_list/topic_rate_limit_whitelist + key_type = KEY_MODE_TEXT + value_type = VALUE_MODE_FLAG diff --git a/code/controllers/subsystem/fail2topic.dm b/code/controllers/subsystem/fail2topic.dm index 01b6d225b9..0c2936e936 100644 --- a/code/controllers/subsystem/fail2topic.dm +++ b/code/controllers/subsystem/fail2topic.dm @@ -1,7 +1,8 @@ SUBSYSTEM_DEF(fail2topic) name = "Fail2Topic" - init_order = SS_INIT_MISC_FIRST - flags = SS_FIRE_IN_LOBBY | SS_BACKGROUND + init_order = INIT_ORDER_FAIL2TOPIC + flags = SS_BACKGROUND + runlevels = ALL var/list/rate_limiting = list() var/list/fail_counts = list() @@ -47,8 +48,13 @@ SUBSYSTEM_DEF(fail2topic) /datum/controller/subsystem/fail2topic/proc/IsRateLimited(ip) var/last_attempt = rate_limiting[ip] - if (config?.api_rate_limit_whitelist[ip]) - return FALSE + var/static/datum/config_entry/keyed_list/topic_rate_limit_whitelist/cached_whitelist_entry + if(!istype(cached_whitelist_entry)) + cached_whitelist_entry = CONFIG_GET(keyed_list/topic_rate_limit_whitelist) + + if(istype(cached_whitelist_entry)) + if(cached_whitelist_entry.config_entry_value[ip]) + return FALSE if (active_bans[ip]) return TRUE