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

tweak: whitelist auto update #1190

Merged
merged 10 commits into from
Apr 20, 2024
Merged
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
1 change: 0 additions & 1 deletion modular_ss220/whitelist/_whitelist.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@

/datum/modpack/whitelist/initialize()
load_whitelist()
GLOB.admin_verbs_server |= /client/proc/update_whitelist
38 changes: 12 additions & 26 deletions modular_ss220/whitelist/code/whitelist.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,28 @@

qdel(whitelist_query)

/client/proc/update_whitelist()
set name = "Update whitelist"
set category = "Server"

if(!check_rights(R_SERVER))
return
/world/IsBanned(key, address, computer_id, type, check_ipintel, check_2fa, check_guest, log_info, check_tos)
var/ckey = ckey(key)

load_whitelist()
if(GLOB.configuration.overflow.reroute_cap != 0.5 || !ckey || (ckey in GLOB.configuration.overflow.overflow_whitelist))
return ..()

/mob/new_player/proc/check_whitelist()
if(!GLOB.configuration.overflow.reroute_cap || !SSdbcore.IsConnected())
return
var/list/denied_entry = list("reason"="no-whitelist", "desc"="\nПричина: Вас ([key]) нет в вайтлисте этого сервера. Приобрести доступ возможно у одного из стримеров Банды за баллы канала или записаться самостоятельно с помощью команды в дискорде, доступной сабам бусти, начиная со второго тира.")
var/datum/db_query/whitelist_query = SSdbcore.NewQuery({"
SELECT ckey FROM ckey_whitelist WHERE ckey=:ckey AND
is_valid=1 AND port=:port AND date_start<=NOW() AND
(NOW()<date_end OR date_end IS NULL)
"}, list("ckey" = ckey, "port" = "[world.port]"))

if(!whitelist_query.warn_execute())
qdel(whitelist_query)
return
return denied_entry

while(whitelist_query.NextRow())
var/ckey = whitelist_query.item[1]
GLOB.configuration.overflow.overflow_whitelist |= ckey
var/ckey_from_db = whitelist_query.item[1]
GLOB.configuration.overflow.overflow_whitelist |= ckey_from_db
qdel(whitelist_query)
return ..()

qdel(whitelist_query)


/mob/new_player/Login()
if(!(ckey in GLOB.configuration.overflow.overflow_whitelist))
check_whitelist()
. = ..()

/world/IsBanned(key, address, computer_id, type, check_ipintel, check_2fa, check_guest, log_info, check_tos)
var/ckey = ckey(key)
if(GLOB.configuration.overflow.reroute_cap == 0.5 && ckey && !(ckey in GLOB.configuration.overflow.overflow_whitelist))
return list("reason"="no-whitelist", "desc"="\nПричина: Вас ([key]) нет в вайтлисте этого сервера. Приобрести доступ возможно у одного из стримеров Банды за баллы канала или записаться самостоятельно с помощью команды в дискорде, доступной сабам бусти, начиная со второго тира.")

. = ..()
return denied_entry
Loading