From 6b4be2d7a8584edd0a35ec96458bd24a72ecb38b Mon Sep 17 00:00:00 2001 From: Arokha Sieyes Date: Tue, 22 May 2018 23:03:53 -0400 Subject: [PATCH] Paranoid logging and byond account age Adds the PARANOIA_LOGGING setting to config.txt (and PANIC_BUNKER which was missing for some reason) and updates example. PARANOIA_LOGGING (also available as a verb for admins in Server) begins notifying admins of any 0day byond accounts, or users who have never joined before. For when you don't quite want to panic bunker. Also makes this information available in player panel. Requires SQL connection. --- code/controllers/configuration.dm | 7 +++++++ code/modules/admin/admin.dm | 5 +++++ code/modules/admin/admin_verbs.dm | 3 ++- code/modules/admin/verbs/panicbunker.dm | 20 ++++++++++++++++-- code/modules/client/client defines.dm | 8 +++++--- code/modules/client/client procs.dm | 27 +++++++++++++++++++++++-- config/example/config.txt | 12 ++++++++--- 7 files changed, 71 insertions(+), 11 deletions(-) diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 29188647f2..f6db4f65d4 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -97,6 +97,7 @@ var/list/gamemode_cache = list() var/guests_allowed = 1 var/debugparanoid = 0 var/panic_bunker = 0 + var/paranoia_logging = 0 var/serverurl var/server @@ -737,6 +738,12 @@ var/list/gamemode_cache = list() if("radiation_lower_limit") radiation_lower_limit = text2num(value) + if ("panic_bunker") + config.panic_bunker = 1 + + if ("paranoia_logging") + config.paranoia_logging = 1 + else log_misc("Unknown setting in configuration: '[name]'") diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index 84aa437c55..1ee7dc9686 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -52,6 +52,11 @@ proc/admin_notice(var/message, var/rights) else body += " \[Heal\] " + if(M.client) + body += "
First connection: [M.client.player_age] days ago" + body += "
BYOND account created: [M.client.account_join_date]" + body += "
BYOND account age (days): [M.client.account_age]" + body += {"

\[ VV - diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 6b038aca4e..2386876cdb 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -174,7 +174,8 @@ var/list/admin_verbs_server = list( /client/proc/nanomapgen_DumpImage, /client/proc/modify_server_news, /client/proc/recipe_dump, - /client/proc/panicbunker + /client/proc/panicbunker, + /client/proc/paranoia_logging ) var/list/admin_verbs_debug = list( diff --git a/code/modules/admin/verbs/panicbunker.dm b/code/modules/admin/verbs/panicbunker.dm index ac31c26071..a997fdcb11 100644 --- a/code/modules/admin/verbs/panicbunker.dm +++ b/code/modules/admin/verbs/panicbunker.dm @@ -1,15 +1,31 @@ /client/proc/panicbunker() set category = "Server" set name = "Toggle Panic Bunker" + + if(!check_rights(R_ADMIN)) + return + if (!config.sql_enabled) to_chat(usr, "The Database is not enabled!") return config.panic_bunker = (!config.panic_bunker) - log_admin("[key_name(usr)] has toggled the Panic Bunker, it is now [(config.panic_bunker?"on":"off")]") - message_admins("[key_name_admin(usr)] has toggled the Panic Bunker, it is now [(config.panic_bunker?"enabled":"disabled")].") + log_and_message_admins("[key_name(usr)] has toggled the Panic Bunker, it is now [(config.panic_bunker?"on":"off")]") if (config.panic_bunker && (!dbcon || !dbcon.IsConnected())) message_admins("The Database is not connected! Panic bunker will not work until the connection is reestablished.") feedback_add_details("admin_verb","PANIC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! +/client/proc/paranoia_logging() + set category = "Server" + set name = "New Player Warnings" + + if(!check_rights(R_ADMIN)) + return + + config.paranoia_logging = (!config.paranoia_logging) + + log_and_message_admins("[key_name(usr)] has toggled Paranoia Logging, it is now [(config.paranoia_logging?"on":"off")]") + if (config.paranoia_logging && (!dbcon || !dbcon.IsConnected())) + message_admins("The Database is not connected! Paranoia logging will not be able to give 'player age' (time since first connection) warnings, only Byond account warnings.") + feedback_add_details("admin_verb","PARLOG") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! diff --git a/code/modules/client/client defines.dm b/code/modules/client/client defines.dm index 09d4738d67..f272fba459 100644 --- a/code/modules/client/client defines.dm +++ b/code/modules/client/client defines.dm @@ -46,9 +46,11 @@ //////////////////////////////////// //things that require the database// //////////////////////////////////// - var/player_age = "Requires database" //So admins know why it isn't working - Used to determine how old the account is - in days. - var/related_accounts_ip = "Requires database" //So admins know why it isn't working - Used to determine what other accounts previously logged in from this ip - var/related_accounts_cid = "Requires database" //So admins know why it isn't working - Used to determine what other accounts previously logged in from this computer id + var/player_age = "(Requires database)" //So admins know why it isn't working - Used to determine how old the account is - in days. + var/related_accounts_ip = "(Requires database)" //So admins know why it isn't working - Used to determine what other accounts previously logged in from this ip + var/related_accounts_cid = "(Requires database)" //So admins know why it isn't working - Used to determine what other accounts previously logged in from this computer id + var/account_join_date = "(Requires database)" + var/account_age = "(Requires database)" preload_rsc = PRELOAD_RSC diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 95ce3456b6..b4b842f0b3 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -162,8 +162,12 @@ winset(src, "rpane.changelog", "background-color=#eaeaea;font-style=bold") if(config.aggressive_changelog) src.changes() - - + + if(config.paranoia_logging) + if(isnum(player_age) && player_age == 0) + log_and_message_admins("PARANOIA: [key_name(src)] has connected here for the first time.") + if(isnum(account_age) && account_age <= 2) + log_and_message_admins("PARANOIA: [key_name(src)] has a very new BYOND account ([account_age] days).") ////////////// //DISCONNECT// @@ -220,6 +224,12 @@ player_age = text2num(query.item[2]) break + account_join_date = sanitizeSQL(findJoinDate()) + if(account_join_date && dbcon.IsConnected()) + var/DBQuery/query_datediff = dbcon.NewQuery("SELECT DATEDIFF(Now(),'[account_join_date]')") + if(query_datediff.Execute() && query_datediff.NextRow()) + account_age = text2num(query_datediff.item[1]) + var/DBQuery/query_ip = dbcon.NewQuery("SELECT ckey FROM erro_player WHERE ip = '[address]'") query_ip.Execute() related_accounts_ip = "" @@ -363,3 +373,16 @@ client/verb/character_setup() set category = "Preferences" if(prefs) prefs.ShowChoices(usr) + +/client/proc/findJoinDate() + var/list/http = world.Export("http://byond.com/members/[ckey]?format=text") + if(!http) + log_world("Failed to connect to byond age check for [ckey]") + return + var/F = file2text(http["CONTENT"]) + if(F) + var/regex/R = regex("joined = \"(\\d{4}-\\d{2}-\\d{2})\"") + if(R.Find(F)) + . = R.group[1] + else + CRASH("Age check regex failed for [src.ckey]") diff --git a/config/example/config.txt b/config/example/config.txt index 23c5818162..d9d73c6ccb 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -243,8 +243,8 @@ GUEST_BAN ## Remove the # to allow special 'Easter-egg' events on special holidays such as seasonal holidays and stuff like 'Talk Like a Pirate Day' :3 YAARRR ALLOW_HOLIDAYS -##Defines the ticklag for the world. 0.9 is the normal one, 0.5 is smoother. -TICKLAG 0.9 +##Defines the ticklag for the world. 0.6 is the normal one, 0.5 is smoother +TICKLAG 0.6 ## Defines if Tick Compensation is used. It results in a minor slowdown of movement of all mobs, but attempts to result in a level movement speed across all ticks. Recommended if tickrate is lowered. TICKCOMP 0 @@ -401,4 +401,10 @@ STARLIGHT 0 #DEFAULT_BRAIN_HEALTH 400 ## Default language prefix keys, separated with spaces. Only single character keys are supported. If unset, defaults to , # and - -# DEFAULT_LANGUAGE_PREFIXES , # - \ No newline at end of file +# DEFAULT_LANGUAGE_PREFIXES , # - + +## Uncomment to enable the Panic Bunker by default. This will prevent all unseen-before players from connecting. Requires SQL. +# PANIC_BUNKER + +## Uncomment to enable Paranoia Logging. This will notify admins and write to a file any time a new player (byond or your server) connects. +# PARANOIA_LOGGING