From 2acde0dd8faf39deabcef32348aeddcf3c5f11dc Mon Sep 17 00:00:00 2001 From: harryob Date: Thu, 1 Feb 2024 20:10:25 +0000 Subject: [PATCH 1/3] removes dead tor code --- .../configuration/entries/general.dm | 2 - code/game/world.dm | 4 - code/modules/admin/IsBanned.dm | 12 +-- code/modules/admin/ToRban.dm | 88 ------------------- code/modules/admin/admin_verbs.dm | 1 - colonialmarines.dme | 1 - 6 files changed, 1 insertion(+), 107 deletions(-) delete mode 100644 code/modules/admin/ToRban.dm diff --git a/code/controllers/configuration/entries/general.dm b/code/controllers/configuration/entries/general.dm index 385cbcb8d446..eb1b0540fb54 100644 --- a/code/controllers/configuration/entries/general.dm +++ b/code/controllers/configuration/entries/general.dm @@ -491,8 +491,6 @@ This maintains a list of ip addresses that are able to bypass topic filtering. /datum/config_entry/flag/respawn -/datum/config_entry/flag/ToRban - /datum/config_entry/flag/ooc_country_flags /datum/config_entry/flag/record_rounds diff --git a/code/game/world.dm b/code/game/world.dm index f68263412715..627e245bc4c1 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -87,10 +87,6 @@ GLOBAL_LIST_INIT(reboot_sfx, file2list("config/reboot_sfx.txt")) GLOB.obfs_x = rand(-500, 500) //A number between -100 and 100 GLOB.obfs_y = rand(-500, 500) //A number between -100 and 100 - spawn(3000) //so we aren't adding to the round-start lag - if(CONFIG_GET(flag/ToRban)) - ToRban_autoupdate() - // If the server's configured for local testing, get everything set up ASAP. // Shamelessly stolen from the test manager's host_tests() proc if(testing_locally) diff --git a/code/modules/admin/IsBanned.dm b/code/modules/admin/IsBanned.dm index 94f40629fc6a..50ad8c92de84 100644 --- a/code/modules/admin/IsBanned.dm +++ b/code/modules/admin/IsBanned.dm @@ -17,6 +17,7 @@ message_admins("Failed Login: [key] - Guests not allowed") return list("reason"="guest", "desc"="\nReason: Guests not allowed. Please sign in with a byond account.") + // wait for database to be ready WAIT_DB_READY if(GLOB.admin_datums[ckey] && (GLOB.admin_datums[ckey].rights & R_MOD)) return ..() @@ -26,19 +27,8 @@ var/datum/entity/player/P = get_player_from_key(ckey) - //check if the IP address is a known TOR node - if(CONFIG_GET(flag/ToRban) && ToRban_isbanned(address)) - log_access("Failed Login: [src] - Banned: ToR") - message_admins("Failed Login: [src] - Banned: ToR") - return list("reason"="Using ToR", "desc"="\nReason: The network you are using to connect has been banned.\nIf you believe this is a mistake, please request help at [CONFIG_GET(string/banappeals)]") - - // wait for database to be ready . = P.check_ban(computer_id, address) - if(.) - return . - - return ..() //default pager ban stuff #endif diff --git a/code/modules/admin/ToRban.dm b/code/modules/admin/ToRban.dm deleted file mode 100644 index 549353facfb8..000000000000 --- a/code/modules/admin/ToRban.dm +++ /dev/null @@ -1,88 +0,0 @@ -//By Carnwennan -//fetches an external list and processes it into a list of ip addresses. -//It then stores the processed list into a savefile for later use -#define TORFILE "data/ToR_ban.bdb" -#define TOR_UPDATE_INTERVAL 216000 //~6 hours - -/proc/ToRban_isbanned(ip_address) - var/savefile/F = new(TORFILE) - if(F) - if( ip_address in F.dir ) - return 1 - return 0 - -/proc/ToRban_autoupdate() - var/savefile/F = new(TORFILE) - if(F) - var/last_update - F["last_update"] >> last_update - if((last_update + TOR_UPDATE_INTERVAL) < world.realtime) //we haven't updated for a while - ToRban_update() - return - -/proc/ToRban_update() - spawn(0) - log_misc("Downloading updated ToR data...") - var/http[] = world.Export("https://check.torproject.org/exit-addresses") - - var/list/rawlist = file2list(http["CONTENT"]) - if(rawlist.len) - fdel(TORFILE) - var/savefile/F = new(TORFILE) - for( var/line in rawlist ) - if(!line) continue - if( copytext(line,1,12) == "ExitAddress" ) - var/cleaned = copytext(line,13,length(line)-19) - if(!cleaned) continue - F[cleaned] << 1 - F["last_update"] << world.realtime - log_misc("ToR data updated!") - if(usr) to_chat(usr, "ToRban updated.") - return - log_misc("ToR data update aborted: no data.") - return - -/client/proc/ToRban(task in list("update","toggle","show","remove","remove all","find")) - set name = "ToR Ban Settings" - set category = "Server" - if(!admin_holder) return - switch(task) - if("update") - ToRban_update() - if("toggle") - if(config) - if(CONFIG_GET(flag/ToRban)) - CONFIG_SET(flag/ToRban, FALSE) - message_admins("ToR banning disabled.") - else - CONFIG_SET(flag/ToRban, TRUE) - message_admins("ToR banning enabled.") - if("show") - var/savefile/F = new(TORFILE) - var/dat - if( length(F.dir) ) - for( var/i=1, i<=length(F.dir), i++ ) - dat += "#[i] [F.dir[i]]" - dat = "[dat]
" - else - dat = "No addresses in list." - src << browse(dat,"window=ToRban_show") - if("remove") - var/savefile/F = new(TORFILE) - var/choice = tgui_input_list(src,"Please select an IP address to remove from the ToR banlist:","Remove ToR ban", F.dir) - if(choice) - F.dir.Remove(choice) - to_chat(src, "Address removed") - if("remove all") - to_chat(src, "[TORFILE] was [fdel(TORFILE)?"":"not "]removed.") - if("find") - var/input = input(src,"Please input an IP address to search for:","Find ToR ban",null) as null|text - if(input) - if(ToRban_isbanned(input)) - to_chat(src, "Address is a known ToR address") - else - to_chat(src, "Address is not a known ToR address") - return - -#undef TORFILE -#undef TOR_UPDATE_INTERVAL diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 56002d139599..43b06b6d80bc 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -242,7 +242,6 @@ GLOBAL_LIST_INIT(admin_verbs_possess, list( )) GLOBAL_LIST_INIT(admin_verbs_permissions, list( - /client/proc/ToRban, /client/proc/whitelist_panel, )) diff --git a/colonialmarines.dme b/colonialmarines.dme index 0b39e89042d2..6beec448e4b4 100644 --- a/colonialmarines.dme +++ b/colonialmarines.dme @@ -1397,7 +1397,6 @@ #include "code\modules\admin\stickyban.dm" #include "code\modules\admin\STUI.dm" #include "code\modules\admin\tag.dm" -#include "code\modules\admin\ToRban.dm" #include "code\modules\admin\medal_panel\medals_panel.dm" #include "code\modules\admin\medal_panel\medals_panel_tgui.dm" #include "code\modules\admin\player_panel\player_action.dm" From 357c9bbbf893e0e2f3810f14a72b2a02c3d5a3ee Mon Sep 17 00:00:00 2001 From: harryob Date: Thu, 1 Feb 2024 20:15:15 +0000 Subject: [PATCH 2/3] good catch --- config/example/config.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/config/example/config.txt b/config/example/config.txt index 8a976e02a580..f9e0956593a9 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -151,9 +151,6 @@ BANAPPEALS https://cm-ss13.com/viewforum.php?f=76 ##Defines the ticklag for the world. 0.9 is the normal one, 0.5 is smoother. TICKLAG 0.5 -## Uncomment this to ban use of ToR -#TOR_BAN - ## Uncomment this to have country flags pop up in OOC alongside names if the user has the pref turned on (uses IP-API) #OOC_COUNTRY_FLAGS From dee5e2ad73a4b7859465ccc90bd2d0782dd19496 Mon Sep 17 00:00:00 2001 From: harryob <55142896+harryob@users.noreply.github.com> Date: Sat, 10 Feb 2024 12:29:30 +0000 Subject: [PATCH 3/3] reverts changes to IsBanned --- code/modules/admin/IsBanned.dm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/modules/admin/IsBanned.dm b/code/modules/admin/IsBanned.dm index 50ad8c92de84..4a7307b247a5 100644 --- a/code/modules/admin/IsBanned.dm +++ b/code/modules/admin/IsBanned.dm @@ -29,6 +29,10 @@ . = P.check_ban(computer_id, address) + if(.) + return . + + return ..() //default pager ban stuff #endif