Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whitelist 3.2 #9079

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@

callHook("startup")
init_vchat()
//Emergency Fix
load_mods()
//end-emergency fix
load_whitelist()

src.update_status()

Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/banjob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var/global/jobban_keylist[0] //to store the keys & ranks
if (guest_jobbans(rank))
if(config.guest_jobban && IsGuestKey(M.key))
return "Guest Job-ban"
if(config.usewhitelist && !M.client.is_whitelisted(rank)) // This outright doesn't work, but at least compiles. AFAIK we don't use this system at present. ~Ater
if(config.usewhitelist && !M.client.is_whitelisted(rank))
return "Whitelisted Job"

return ckey_is_jobbanned(M.ckey, rank)
Expand Down
8 changes: 1 addition & 7 deletions code/modules/admin/topic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1944,13 +1944,7 @@
var/client/C = locate(href_list["modify_whitelist"])
if(!istype(C))
return
var/entry = input(usr, "Please enter the path of the whitelist you wish to modify:", "Whitelist target", "") as text|null
if(!entry || !ispath(text2path(entry)))
return
if(href_list["set_value"] == "1")
C.add_whitelist(entry)
else if(href_list["set_value"] == "0")
C.remove_whitelist(entry)
usr.client.admin_modify_whitelist((href_list["set_value"] == "1"), ckey(C.ckey))

/mob/living/proc/can_centcom_reply()
return 0
Expand Down
2 changes: 1 addition & 1 deletion code/modules/client/preference_setup/general/03_body.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
// That last list is entirely arbitrary. Take complaints up with Kholdstare.
if((istype(client) && check_rights(R_ADMIN | R_EVENT | R_FUN, 0, client)) || \
(LAZYLEN(instance.species_allowed) && species && (species in instance.species_allowed)) || \
(config.genemod_whitelist && client.is_whitelisted(/whitelist/genemod) && LAZYLEN(instance.whitelist_allowed) && (species in instance.whitelist_allowed)))
(config.genemod_whitelist && client.is_whitelisted("Genemods") && LAZYLEN(instance.whitelist_allowed) && (species in instance.whitelist_allowed)))
.[instance.name] = instance

/datum/category_item/player_setup_item/general/body
Expand Down
123 changes: 123 additions & 0 deletions code/modules/whitelist/admin.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// Rewrites the whitelists to disk
/proc/write_whitelist()
var/filename = "config/whitelists.json"
log_admin("Writing whitelists to disk at `[filename]`")
try
// Byond doesn't have a mechanism for in-place modification of a file, so we have to make a new one and then overwrite the old one.
// If this is interrupted, the .tmp file exists and can be loaded at the start of the next round.
// The in-game list represents the set of valid entries within the whitelist file, so we may as well remove invalid lines in the process.
text2file(json_encode(global.whitelists), filename + ".tmp")
if(fexists(filename) && !fdel(filename))
error("Exception when overwriting whitelist file [filename]")
if(fcopy(filename + ".tmp", filename))
if(!fdel(filename + ".tmp"))
error("Exception when deleting tmp whitelist file [filename].tmp")
catch(var/exception/E)
error("Exception when writing to whitelist file [filename]: [E]")


// Add the selected path to the player's whitelists, if it's valid.
/client/proc/add_whitelist(var/w_key)
if(istype(w_key, /datum))
var/datum/D = w_key
w_key = D:name
if(!istext(w_key))
return FALSE // Not set.
// If they're already whitelisted, do nothing (Also loads the whitelist)
if(is_whitelisted(w_key))
return

log_and_message_admins("[usr ? usr : "SYSTEM"] gave [w_key] whitelist to [src]", usr)
if(!islist(global.whitelists[ckey(ckey)]))
global.whitelists[ckey(ckey)] = list()
global.whitelists[ckey(ckey)] += w_key
write_whitelist()

// Remove the selected path from the player's whitelists.
/client/proc/remove_whitelist(var/w_key)
if(istype(w_key, /datum))
var/datum/D = w_key
w_key = D:name
if(!istext(w_key))
return FALSE // Not set.
// If they're not whitelisted, do nothing (Also loads the whitelist)
if(!is_whitelisted(w_key))
return

log_and_message_admins("[usr ? usr : "SYSTEM"] removed [w_key] whitelist from [src]", usr)
global.whitelists[ckey] -= w_key
write_whitelist()


/client/proc/admin_add_whitelist()
set name = "Whitelist Add Player"
set category = "Admin"
set desc = "Give a whitelist to a target player"
admin_modify_whitelist(TRUE)


/client/proc/admin_del_whitelist()
set name = "Whitelist Remove Player"
set category = "Admin"
set desc = "Remove a whitelist from the target player"
admin_modify_whitelist(FALSE)


/client/proc/admin_modify_whitelist(var/set_value, var/key = null)
if(!check_rights(R_ADMIN|R_DEBUG))
return

// Get the person to whitelist.
if(!key)
key = input(src, "Please enter the CKEY of the player whose whitelist you wish to modify:", "Whitelist ckey", "") as text|null
if(!key || !length(key))
return

key = ckey(key)

// Get the whitelist thing to modify.
var/entry = input(src, "Please enter the name of the whitelist you wish to modify:", "Whitelist target", "") as null|anything in global.whitelistable
if(!entry)
return

if(set_value)
if(!islist(global.whitelists[key]))
global.whitelists[key] = list()
else
to_world("is a list: [global.whitelists[ckey(ckey)]]")
if(entry in global.whitelists[key])
to_chat(src, SPAN_NOTICE("[key] is already whitelisted for [entry]!"))
return
global.whitelists[key] += entry
else
if(!islist(global.whitelists[key]))
to_chat(src, SPAN_NOTICE("[key] isn't whitelisted for anything!"))
return
global.whitelists[key] -= entry

log_and_message_admins("[src] [set_value ? "gave [entry] whitelist to" : "removed [entry] whitelist from"] [key]", src)

write_whitelist()


/client/vv_get_dropdown()
. = ..()
VV_DROPDOWN_OPTION(VV_HK_ADD_WHITELIST, "Add whitelist")
VV_DROPDOWN_OPTION(VV_HK_DEL_WHITELIST, "Remove whitelist")


/client/vv_do_topic(list/href_list)
. = ..()
IF_VV_OPTION(VV_HK_ADD_WHITELIST)
if(!check_rights(R_ADMIN|R_DEBUG))
return
var/client/C = locate(href_list["target"])
if(istype(C))
usr.client.admin_modify_whitelist(TRUE, ckey(C.ckey))

IF_VV_OPTION(VV_HK_DEL_WHITELIST)
if(!check_rights(R_ADMIN|R_DEBUG))
return
var/client/C = locate(href_list["target"])
if(istype(C))
usr.client.admin_modify_whitelist(FALSE, ckey(C.ckey))
125 changes: 0 additions & 125 deletions code/modules/whitelist/admin_ops.dm

This file was deleted.

65 changes: 0 additions & 65 deletions code/modules/whitelist/legacy.dm

This file was deleted.

4 changes: 0 additions & 4 deletions code/modules/whitelist/phony_paths.dm

This file was deleted.

Loading
Loading