Randmutb will no longer select and mutate RACEBLOCK - mutagen, cloning, radiation-events etc will no longer cause this block to change.

IsBanned() now only processes the key into a ckey once...rather than several times.
This commit is contained in:
carnie
2013-08-21 15:43:38 +01:00
parent 01e87ce2a9
commit e217ef760e
3 changed files with 13 additions and 16 deletions
+10 -14
View File
@@ -1,7 +1,8 @@
//Blocks an attempt to connect before even creating our client datum thing.
world/IsBanned(key,address,computer_id)
if(ckey(key) in admin_datums)
var/ckey = ckey(key)
if(ckey in admin_datums)
//It has proven to be a bad idea to make admins completely immune to bans, making them have to wait for someone with daemon access
//to add a daemon ban to finally stop them. Admin tempbans and admin permabans are special, high-level ban types, which are there to help
//deal with rogue admins quicker. If admin tempbans or admin permabans are ever needed, it should be consider a big deal. The same applies if
@@ -9,14 +10,12 @@ world/IsBanned(key,address,computer_id)
//computer id, set it on his computer, get himself banned, resulting in the admin getting banned aswell. - this happens to also be the reason why
//admins were immune to bans in the first place.
if(!config.ban_legacy_system)
var/ckeytext = ckey(key)
if(!establish_db_connection())
world.log << "Ban database connection failure. Admin [ckeytext] not checked"
diary << "Ban database connection failure. Admin [ckeytext] not checked"
world.log << "Ban database connection failure. Admin [ckey] not checked"
diary << "Ban database connection failure. Admin [ckey] not checked"
return
var/DBQuery/query = dbcon.NewQuery("SELECT ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM erro_Ban WHERE (ckey = '[ckeytext]') AND (bantype = 'ADMIN_PERMABAN' OR (bantype = 'ADMIN_TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)")
var/DBQuery/query = dbcon.NewQuery("SELECT ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM erro_Ban WHERE (ckey = '[ckey]') AND (bantype = 'ADMIN_PERMABAN' OR (bantype = 'ADMIN_TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)")
query.Execute()
@@ -52,14 +51,14 @@ world/IsBanned(key,address,computer_id)
log_access("Failed Login: [src] - Banned: ToR")
message_admins("\blue Failed Login: [src] - Banned: ToR")
//ban their computer_id and ckey for posterity
AddBan(ckey(key), computer_id, "Use of ToR", "Automated Ban", 0, 0)
AddBan(ckey, computer_id, "Use of ToR", "Automated Ban", 0, 0)
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.banappeals]")
if(config.ban_legacy_system)
//Ban Checking
. = CheckBan( ckey(key), computer_id, address )
. = CheckBan( ckey, computer_id, address )
if(.)
log_access("Failed Login: [key] [computer_id] [address] - Banned [.["reason"]]")
message_admins("\blue Failed Login: [key] id:[computer_id] ip:[address] - Banned [.["reason"]]")
@@ -68,12 +67,9 @@ world/IsBanned(key,address,computer_id)
return ..() //default pager ban stuff
else
var/ckeytext = ckey(key)
if(!establish_db_connection())
world.log << "Ban database connection failure. Key [ckeytext] not checked"
diary << "Ban database connection failure. Key [ckeytext] not checked"
world.log << "Ban database connection failure. Key [ckey] not checked"
diary << "Ban database connection failure. Key [ckey] not checked"
return
var/failedcid = 1
@@ -89,7 +85,7 @@ world/IsBanned(key,address,computer_id)
failedcid = 0
cidquery = " OR computerid = '[computer_id]' "
var/DBQuery/query = dbcon.NewQuery("SELECT ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM erro_Ban WHERE (ckey = '[ckeytext]' [ipquery] [cidquery]) AND (bantype = 'PERMABAN' OR (bantype = 'TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)")
var/DBQuery/query = dbcon.NewQuery("SELECT ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM erro_Ban WHERE (ckey = '[ckey]' [ipquery] [cidquery]) AND (bantype = 'PERMABAN' OR (bantype = 'TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)")
query.Execute()