From bf6648b3a95eb9ccc05e2c5893a5b0885dff4e29 Mon Sep 17 00:00:00 2001 From: Striders13 <53361823+Striders13@users.noreply.github.com> Date: Sat, 19 Aug 2023 23:19:55 +0500 Subject: [PATCH] Makes client upload limit a config, bumps admin file size upload limit to 5mb (from 2.5mb) (#77708) ## About The Pull Request Makes client upload limit a config. Increases max file size admins can upload to 5mb, up from 2.5mb. ## Why It's Good For The Game Makes it easier to do custom maps for events. Some of our in-game maps are already larger than 2.5mb (delta is almost 3mb). ## Changelog :cl: admin: admins can now upload files to the server up to 5mb (used to be 2.5mb) config: file upload restriction is now config /:cl: --- code/controllers/configuration/entries/general.dm | 8 ++++++++ code/modules/client/client_procs.dm | 15 ++++++--------- config/config.txt | 6 ++++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/code/controllers/configuration/entries/general.dm b/code/controllers/configuration/entries/general.dm index 27e9c6fae74..466ebb53dd8 100644 --- a/code/controllers/configuration/entries/general.dm +++ b/code/controllers/configuration/entries/general.dm @@ -701,3 +701,11 @@ /datum/config_entry/flag/config_errors_runtime default = FALSE + +/datum/config_entry/number/upload_limit + default = 524288 + min_val = 0 + +/datum/config_entry/number/upload_limit_admin + default = 5242880 + min_val = 0 diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index 32763f6e81d..58dca3d9b22 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -1,8 +1,6 @@ //////////// //SECURITY// //////////// -#define UPLOAD_LIMIT 524288 //Restricts client uploads to the server to 0.5MB -#define UPLOAD_LIMIT_ADMIN 2621440 //Restricts admin client uploads to the server to 2.5MB GLOBAL_LIST_INIT(blacklisted_builds, list( "1407" = "bug preventing client display overrides from working leads to clients being able to see things/mobs they shouldn't be able to see", @@ -203,12 +201,14 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( //This stops files larger than UPLOAD_LIMIT being sent from client to server via input(), client.Import() etc. /client/AllowUpload(filename, filelength) + var/client_max_file_size = CONFIG_GET(number/upload_limit) if (holder) - if(filelength > UPLOAD_LIMIT_ADMIN) - to_chat(src, "Error: AllowUpload(): File Upload too large. Upload Limit: [UPLOAD_LIMIT_ADMIN/1024]KiB.") + var/admin_max_file_size = CONFIG_GET(number/upload_limit_admin) + if(filelength > admin_max_file_size) + to_chat(src, span_warning("Error: AllowUpload(): File Upload too large. Upload Limit: [admin_max_file_size/1024]KiB.")) return FALSE - else if(filelength > UPLOAD_LIMIT) - to_chat(src, "Error: AllowUpload(): File Upload too large. Upload Limit: [UPLOAD_LIMIT/1024]KiB.") + else if(filelength > client_max_file_size) + to_chat(src, span_warning("Error: AllowUpload(): File Upload too large. Upload Limit: [client_max_file_size/1024]KiB.")) return FALSE return TRUE @@ -911,8 +911,6 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( add_verb(src, /client/proc/export_preferences) -#undef UPLOAD_LIMIT - //checks if a client is afk //3000 frames = 5 minutes /client/proc/is_afk(duration = CONFIG_GET(number/inactivity_period)) @@ -1238,4 +1236,3 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( #undef LIMITER_SIZE #undef MINUTE_COUNT #undef SECOND_COUNT -#undef UPLOAD_LIMIT_ADMIN diff --git a/config/config.txt b/config/config.txt index 56da612c51f..e262bc25706 100644 --- a/config/config.txt +++ b/config/config.txt @@ -584,3 +584,9 @@ TOAST_NOTIFICATION_ON_INIT ## Causes configuration errors to spit out runtimes CONFIG_ERRORS_RUNTIME + +## Restricts client uploads to the server, defined in bytes, default is 0.5MB +UPLOAD_LIMIT 524288 + +## Restricts admin client uploads to the server, defined in bytes, default is 5MB +UPLOAD_LIMIT_ADMIN 5242880