mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
Spiritual successor and extension to #17798, an almost entire rebuild of the SQL ban system backend and interface. Bantypes are removed per #8584 and #6174. All bans are now 'role bans', server bans are when a ban's role is server. Admin bans are a column, meaning it's possible to ban admins from jobs. Bans now have only an expiry datetime, duration is calculated from this when queried. unbanned column is removed as it's superfluous, checking unban status is now done through checking unban_datetime. unban_round_id column added. Each ip and computerid columns rearranged so ip is always first, like in other tables. Bans now permit a null ckey, ip and computerid. Ban checking is split into two procs now is_banned_from() does a check if a ckey is banned from one or more roles and returns true or false. This effectively replaces jobban_isbanned() used in simple if() statements. If connected a client's ban cache is checked rather than querying the DB. This makes it possible for a client connected to two or more servers to ignore any bans made on one server until their ban cache is rebuilt on the others. Could be avoided with cross-server calls to update ban caches or just the removal of the ban cache but as is I've done neither since I think it's enough of an edge case to not be worth it. The second proc is is_banned_from_with_details(), this queries the DB for a role ban on a player's ckey, ip or CID and returns the details. This replaces direct queries in IsBanned.dm and the preferences menu. The legacy ban system is removed. The interfaces for banning, unbanning and editing bans have been remade to require less clicking and easier simultaneous operations. The banning and jobban panel are combined. They also store player connection details when opened so a client disconnecting no longer stops a ban being placed. New banning panel: Key, IP and CID can all be toggled to allow excluding them from a ban. Checking Use IP and CID from last connection lets you enter only a ckey and have the DB fill these fields in for you, if possible. Temporary bans have a drop-menu which lets you select between seconds, minutes, hours, days, weeks, months and years so you don't need to calculate how many minutes a long ban would be. The ban is still converted into minutes on the DB however. Checking any of the head roles will check both of the boxes for you. The red role box indicates there is already a ban on that role for this ckey. You can apply additional role bans to stack them. New unbanning panel: Unbanning panel is now separate from the banning panel but otherwise functionally the same. Ban editing panel: Actually just a modified banning panel, all the features from it work the same here. You can now edit almost all parameters of a ban instead of just the reason. You can't edit severity as it's not really part of the ban. The panels have been tested but I've not been able to get my local server to be accessible so ban functionality isn't properly confirmed. Plenty of testing will be required as I'd rather not break bans. cl admin: Ban interface rework. The banning and unbanning panels have received a new design which is easier to use and allows multiple role bans to be made at once. prefix: Ban search and unbanning moved to unbanning panel, which is now a separate panel to the old banning panel. /cl
306 lines
9.8 KiB
Plaintext
306 lines
9.8 KiB
Plaintext
#define RESTART_COUNTER_PATH "data/round_counter.txt"
|
|
|
|
GLOBAL_VAR(restart_counter)
|
|
//TODO: Replace INFINITY with the version that fixes http://www.byond.com/forum/?post=2407430
|
|
GLOBAL_VAR_INIT(bypass_tgs_reboot, world.system_type == UNIX && world.byond_build < INFINITY)
|
|
|
|
//This happens after the Master subsystem new(s) (it's a global datum)
|
|
//So subsystems globals exist, but are not initialised
|
|
/world/New()
|
|
|
|
log_world("World loaded at [time_stamp()]!")
|
|
|
|
SetupExternalRSC()
|
|
|
|
GLOB.config_error_log = GLOB.world_manifest_log = GLOB.world_pda_log = GLOB.world_job_debug_log = GLOB.sql_error_log = GLOB.world_href_log = GLOB.world_runtime_log = GLOB.world_attack_log = GLOB.world_game_log = "data/logs/config_error.[GUID()].log" //temporary file used to record errors with loading config, moved to log directory once logging is set bl
|
|
|
|
make_datum_references_lists() //initialises global lists for referencing frequently used datums (so that we only ever do it once)
|
|
|
|
TgsNew(new /datum/tgs_event_handler/tg, minimum_required_security_level = TGS_SECURITY_TRUSTED)
|
|
|
|
GLOB.revdata = new
|
|
|
|
config.Load(params[OVERRIDE_CONFIG_DIRECTORY_PARAMETER])
|
|
|
|
//SetupLogs depends on the RoundID, so lets check
|
|
//DB schema and set RoundID if we can
|
|
SSdbcore.CheckSchemaVersion()
|
|
SSdbcore.SetRoundID()
|
|
SetupLogs()
|
|
|
|
#ifndef USE_CUSTOM_ERROR_HANDLER
|
|
world.log = file("[GLOB.log_directory]/dd.log")
|
|
#endif
|
|
|
|
load_admins()
|
|
load_yogs_stuff() // yogs - Donators
|
|
refresh_admin_files() //yogs - DB support
|
|
LoadVerbs(/datum/verbs/menu)
|
|
if(CONFIG_GET(flag/usewhitelist))
|
|
load_whitelist()
|
|
<<<<<<< HEAD
|
|
LoadBans()
|
|
setup_pretty_filter() //yogs
|
|
=======
|
|
>>>>>>> 8a66665e95... Ban system and interface update (#41176)
|
|
|
|
GLOB.timezoneOffset = text2num(time2text(0,"hh")) * 36000
|
|
|
|
if(fexists(RESTART_COUNTER_PATH))
|
|
GLOB.restart_counter = text2num(trim(file2text(RESTART_COUNTER_PATH)))
|
|
fdel(RESTART_COUNTER_PATH)
|
|
|
|
if(NO_INIT_PARAMETER in params)
|
|
return
|
|
|
|
Master.Initialize(10, FALSE, TRUE)
|
|
|
|
if(TEST_RUN_PARAMETER in params)
|
|
HandleTestRun()
|
|
|
|
/world/proc/HandleTestRun()
|
|
//trigger things to run the whole process
|
|
Master.sleep_offline_after_initializations = FALSE
|
|
SSticker.start_immediately = TRUE
|
|
CONFIG_SET(number/round_end_countdown, 0)
|
|
var/datum/callback/cb
|
|
#ifdef UNIT_TESTS
|
|
cb = CALLBACK(GLOBAL_PROC, /proc/RunUnitTests)
|
|
#else
|
|
cb = VARSET_CALLBACK(SSticker, force_ending, TRUE)
|
|
#endif
|
|
SSticker.OnRoundstart(CALLBACK(GLOBAL_PROC, /proc/addtimer, cb, 10 SECONDS))
|
|
|
|
/world/proc/SetupExternalRSC()
|
|
#if (PRELOAD_RSC == 0)
|
|
GLOB.external_rsc_urls = world.file2list("[global.config.directory]/external_rsc_urls.txt","\n")
|
|
var/i=1
|
|
while(i<=GLOB.external_rsc_urls.len)
|
|
if(GLOB.external_rsc_urls[i])
|
|
i++
|
|
else
|
|
GLOB.external_rsc_urls.Cut(i,i+1)
|
|
#endif
|
|
|
|
/world/proc/SetupLogs()
|
|
var/override_dir = params[OVERRIDE_LOG_DIRECTORY_PARAMETER]
|
|
if(!override_dir)
|
|
var/realtime = world.realtime
|
|
var/texttime = time2text(realtime, "YYYY/MM/DD")
|
|
GLOB.log_directory = "data/logs/[texttime]/round-"
|
|
GLOB.picture_logging_prefix = "L_[time2text(realtime, "YYYYMMDD")]_"
|
|
GLOB.picture_log_directory = "data/picture_logs/[texttime]/round-"
|
|
if(GLOB.round_id)
|
|
GLOB.log_directory += "[GLOB.round_id]"
|
|
GLOB.picture_logging_prefix += "R_[GLOB.round_id]_"
|
|
GLOB.picture_log_directory += "[GLOB.round_id]"
|
|
else
|
|
var/timestamp = replacetext(time_stamp(), ":", ".")
|
|
GLOB.log_directory += "[timestamp]"
|
|
GLOB.picture_log_directory += "[timestamp]"
|
|
GLOB.picture_logging_prefix += "T_[timestamp]_"
|
|
else
|
|
GLOB.log_directory = "data/logs/[override_dir]"
|
|
GLOB.picture_logging_prefix = "O_[override_dir]_"
|
|
GLOB.picture_log_directory = "data/picture_logs/[override_dir]"
|
|
|
|
GLOB.world_game_log = "[GLOB.log_directory]/game.log"
|
|
GLOB.world_mecha_log = "[GLOB.log_directory]/mecha.log"
|
|
GLOB.world_attack_log = "[GLOB.log_directory]/attack.log"
|
|
GLOB.world_pda_log = "[GLOB.log_directory]/pda.log"
|
|
GLOB.world_telecomms_log = "[GLOB.log_directory]/telecomms.log"
|
|
GLOB.world_manifest_log = "[GLOB.log_directory]/manifest.log"
|
|
GLOB.world_href_log = "[GLOB.log_directory]/hrefs.log"
|
|
GLOB.sql_error_log = "[GLOB.log_directory]/sql.log"
|
|
GLOB.world_qdel_log = "[GLOB.log_directory]/qdel.log"
|
|
GLOB.world_runtime_log = "[GLOB.log_directory]/runtime.log"
|
|
GLOB.query_debug_log = "[GLOB.log_directory]/query_debug.log"
|
|
GLOB.world_job_debug_log = "[GLOB.log_directory]/job_debug.log"
|
|
|
|
#ifdef UNIT_TESTS
|
|
GLOB.test_log = file("[GLOB.log_directory]/tests.log")
|
|
start_log(GLOB.test_log)
|
|
#endif
|
|
start_log(GLOB.world_game_log)
|
|
start_log(GLOB.world_attack_log)
|
|
start_log(GLOB.world_pda_log)
|
|
start_log(GLOB.world_telecomms_log)
|
|
start_log(GLOB.world_manifest_log)
|
|
start_log(GLOB.world_href_log)
|
|
start_log(GLOB.world_qdel_log)
|
|
start_log(GLOB.world_runtime_log)
|
|
start_log(GLOB.world_job_debug_log)
|
|
|
|
GLOB.changelog_hash = md5('html/changelog.html') //for telling if the changelog has changed recently
|
|
if(fexists(GLOB.config_error_log))
|
|
fcopy(GLOB.config_error_log, "[GLOB.log_directory]/config_error.log")
|
|
fdel(GLOB.config_error_log)
|
|
|
|
if(GLOB.round_id)
|
|
log_game("Round ID: [GLOB.round_id]")
|
|
|
|
// This was printed early in startup to the world log and config_error.log,
|
|
// but those are both private, so let's put the commit info in the runtime
|
|
// log which is ultimately public.
|
|
log_runtime(GLOB.revdata.get_log_message())
|
|
|
|
/world/Topic(T, addr, master, key)
|
|
TGS_TOPIC //redirect to server tools if necessary
|
|
|
|
var/static/list/topic_handlers = TopicHandlers()
|
|
|
|
var/list/input = params2list(T)
|
|
var/datum/world_topic/handler
|
|
for(var/I in topic_handlers)
|
|
if(I in input)
|
|
handler = topic_handlers[I]
|
|
break
|
|
|
|
if((!handler || initial(handler.log)) && config && CONFIG_GET(flag/log_world_topic))
|
|
log_topic("\"[T]\", from:[addr], master:[master], key:[key]")
|
|
|
|
if(!handler)
|
|
return
|
|
|
|
handler = new handler()
|
|
return handler.TryRun(input)
|
|
|
|
/world/proc/AnnouncePR(announcement, list/payload)
|
|
var/static/list/PRcounts = list() //PR id -> number of times announced this round
|
|
var/id = "[payload["pull_request"]["id"]]"
|
|
if(!PRcounts[id])
|
|
PRcounts[id] = 1
|
|
else
|
|
++PRcounts[id]
|
|
if(PRcounts[id] > PR_ANNOUNCEMENTS_PER_ROUND)
|
|
return
|
|
|
|
var/final_composed = "<span class='announce'>PR: [announcement]</span>"
|
|
for(var/client/C in GLOB.clients)
|
|
C.AnnouncePR(final_composed)
|
|
|
|
/world/proc/FinishTestRun()
|
|
set waitfor = FALSE
|
|
var/list/fail_reasons
|
|
if(GLOB)
|
|
if(GLOB.total_runtimes != 0)
|
|
fail_reasons = list("Total runtimes: [GLOB.total_runtimes]")
|
|
#ifdef UNIT_TESTS
|
|
if(GLOB.failed_any_test)
|
|
LAZYADD(fail_reasons, "Unit Tests failed!")
|
|
#endif
|
|
if(!GLOB.log_directory)
|
|
LAZYADD(fail_reasons, "Missing GLOB.log_directory!")
|
|
else
|
|
fail_reasons = list("Missing GLOB!")
|
|
if(!fail_reasons)
|
|
text2file("Success!", "[GLOB.log_directory]/clean_run.lk")
|
|
else
|
|
log_world("Test run failed!\n[fail_reasons.Join("\n")]")
|
|
sleep(0) //yes, 0, this'll let Reboot finish and prevent byond memes
|
|
qdel(src) //shut it down
|
|
|
|
/world/Reboot(reason = 0, fast_track = FALSE)
|
|
if (reason || fast_track) //special reboot, do none of the normal stuff
|
|
if (usr)
|
|
log_admin("[key_name(usr)] Has requested an immediate world restart via client side debugging tools")
|
|
message_admins("[key_name_admin(usr)] Has requested an immediate world restart via client side debugging tools")
|
|
to_chat(world, "<span class='boldannounce'>Rebooting World immediately due to host request</span>")
|
|
else
|
|
to_chat(world, "<span class='boldannounce'>Rebooting world...</span>")
|
|
Master.Shutdown() //run SS shutdowns
|
|
|
|
if(!GLOB.bypass_tgs_reboot)
|
|
TgsReboot()
|
|
|
|
if(TEST_RUN_PARAMETER in params)
|
|
FinishTestRun()
|
|
return
|
|
|
|
if(TgsAvailable())
|
|
var/do_hard_reboot
|
|
// check the hard reboot counter
|
|
var/ruhr = CONFIG_GET(number/rounds_until_hard_restart)
|
|
switch(ruhr)
|
|
if(-1)
|
|
do_hard_reboot = FALSE
|
|
if(0)
|
|
do_hard_reboot = TRUE
|
|
else
|
|
if(GLOB.restart_counter >= ruhr)
|
|
do_hard_reboot = TRUE
|
|
else
|
|
text2file("[++GLOB.restart_counter]", RESTART_COUNTER_PATH)
|
|
do_hard_reboot = FALSE
|
|
|
|
if(do_hard_reboot)
|
|
log_world("World hard rebooted at [time_stamp()]")
|
|
shutdown_logging() // See comment below.
|
|
TgsEndProcess()
|
|
|
|
log_world("World rebooted at [time_stamp()]")
|
|
shutdown_logging() // Past this point, no logging procs can be used, at risk of data loss.
|
|
..()
|
|
|
|
/world/proc/update_status()
|
|
|
|
var/list/features = list()
|
|
|
|
if(GLOB.master_mode)
|
|
features += GLOB.master_mode
|
|
|
|
if (!GLOB.enter_allowed)
|
|
features += "closed"
|
|
|
|
var/s = ""
|
|
var/hostedby
|
|
if(config)
|
|
var/server_name = CONFIG_GET(string/servername)
|
|
if (server_name)
|
|
s += "<b>[server_name]</b> — "
|
|
features += "[CONFIG_GET(flag/norespawn) ? "no " : ""]respawn"
|
|
if(CONFIG_GET(flag/allow_vote_mode))
|
|
features += "vote"
|
|
if(CONFIG_GET(flag/allow_ai))
|
|
features += "AI allowed"
|
|
hostedby = CONFIG_GET(string/hostedby)
|
|
|
|
s += "<b>[station_name()]</b>";
|
|
s += " ("
|
|
s += "<a href=\"http://\">" //Change this to wherever you want the hub to link to.
|
|
s += "Default" //Replace this with something else. Or ever better, delete it and uncomment the game version.
|
|
s += "</a>"
|
|
s += ")"
|
|
|
|
var/n = 0
|
|
for (var/mob/M in GLOB.player_list)
|
|
if (M.client)
|
|
n++
|
|
|
|
if (n > 1)
|
|
features += "~[n] players"
|
|
else if (n > 0)
|
|
features += "~[n] player"
|
|
|
|
if (!host && hostedby)
|
|
features += "hosted by <b>[hostedby]</b>"
|
|
|
|
if (features)
|
|
s += ": [jointext(features, ", ")]"
|
|
|
|
status = s
|
|
|
|
/world/proc/update_hub_visibility(new_visibility)
|
|
if(new_visibility == GLOB.hub_visibility)
|
|
return
|
|
GLOB.hub_visibility = new_visibility
|
|
if(GLOB.hub_visibility)
|
|
hub_password = "kMZy3U5jJHSiBQjr"
|
|
else
|
|
hub_password = "SORRYNOPASSWORD"
|
|
|
|
/world/proc/incrementMaxZ()
|
|
maxz++
|
|
SSmobs.MaxZChanged()
|
|
SSidlenpcpool.MaxZChanged()
|