Skip to content

Commit

Permalink
Adds a ckey whitelist, stripping out some dead code (#21875)
Browse files Browse the repository at this point in the history
* Adds a whitelist, stripping out some dead code in the process

Old job whitelist that wasn't used has been removed.

Config has been repurposed, uncomment USEWHITELIST, only ckey's in
admins.txt or whitelist.txt in the config will be allowed to connect to
the server

* More examples

* Add a guy

* Update whitelist.txt

* Put him in
  • Loading branch information
optimumtact authored and Jordie0608 committed Dec 4, 2016
1 parent f46d9c9 commit f3acff4
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 20 deletions.
2 changes: 1 addition & 1 deletion code/controllers/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
if("guest_ban")
guests_allowed = 0
if("usewhitelist")
config.usewhitelist = 1
config.usewhitelist = TRUE
if("allow_metadata")
config.allow_Metadata = 1
if("kick_inactive")
Expand Down
11 changes: 11 additions & 0 deletions code/modules/admin/IsBanned.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
if((ckey in admin_datums) || (ckey in deadmins))
admin = 1

//Whitelist
if(config.usewhitelist)
if(!check_whitelist(ckey(key)))
if (admin)
log_admin("The admin [key] has been allowed to bypass the whitelist")
message_admins("<span class='adminnotice'>The admin [key] has been allowed to bypass the whitelist</span>")
addclientmessage(ckey,"<span class='adminnotice'>You have been allowed to bypass the whitelist</span>")
else
log_access("Failed Login: [key] - Not on whitelist")
return list("reason"="whitelist", "desc" = "\nReason: You are not on the white list for this server")

//Guest Checking
if(IsGuestKey(key))
if (!guests_allowed)
Expand Down
22 changes: 22 additions & 0 deletions code/modules/admin/whitelist.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#define WHITELISTFILE "config/whitelist.txt"

var/list/whitelist

/proc/load_whitelist()
whitelist = list()
for(var/line in file2list(WHITELISTFILE))
if(!line)
continue
if(findtextEx(line,"#",1,2))
continue
whitelist += line

if(!whitelist.len)
whitelist = null

/proc/check_whitelist(var/ckey)
if(!whitelist)
return FALSE
. = (ckey in whitelist)

#undef WHITELISTFILE
15 changes: 0 additions & 15 deletions code/modules/jobs/whitelist.dm

This file was deleted.

5 changes: 2 additions & 3 deletions config/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,8 @@ CHECK_RANDOMIZER
## byond membership starts at $10 for 3 months, so to use the webclient to evade, they would have sink 10 bucks in each evade.
#WEBCLIENT_ONLY_BYOND_MEMBERS

## Set to jobban everyone who's key is not listed in data/whitelist.txt from Captain, HoS, HoP, CE, RD, CMO, Warden, Security, Detective, and AI positions.
## Uncomment to 1 to jobban, leave commented out to allow these positions for everyone (but see GUEST_JOBBAN above and regular jobbans)
# USEWHITELIST
## Set to prevent anyone but those ckeys listed in config/whitelist.txt and config/admins.txt from joining your server
#USEWHITELIST

## set a server location for world reboot. Don't include the byond://, just give the address and port.
# Don't set this to the same server, BYOND will automatically restart players to the server when it has restarted.
Expand Down
9 changes: 9 additions & 0 deletions config/whitelist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
###############################################################################################
# Basically, a list of ckeys who make it past user connection #
# Case is not important for ckey. #
###############################################################################################
#Optimumtact
#kevinz000
#Iamgoofball
#Rshoe95
#That one penguin who became an admin
2 changes: 1 addition & 1 deletion tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@
#include "code\modules\admin\stickyban.dm"
#include "code\modules\admin\topic.dm"
#include "code\modules\admin\watchlist.dm"
#include "code\modules\admin\whitelist.dm"
#include "code\modules\admin\DB_ban\functions.dm"
#include "code\modules\admin\permissionverbs\permissionedit.dm"
#include "code\modules\admin\verbs\adminhelp.dm"
Expand Down Expand Up @@ -1307,7 +1308,6 @@
#include "code\modules\hydroponics\grown\towercap.dm"
#include "code\modules\jobs\access.dm"
#include "code\modules\jobs\jobs.dm"
#include "code\modules\jobs\whitelist.dm"
#include "code\modules\jobs\job_types\assistant.dm"
#include "code\modules\jobs\job_types\captain.dm"
#include "code\modules\jobs\job_types\cargo_service.dm"
Expand Down

0 comments on commit f3acff4

Please sign in to comment.