[MIRROR] Makes a thing use the right proc (#881)
* Makes a thing use the right proc * Delete IsBanned.dm.rej * Update IsBanned.dm * Update IsBanned.dm
This commit is contained in:
committed by
Poojawa
parent
eb359f1014
commit
30e18146e5
+193
-192
@@ -1,195 +1,196 @@
|
|||||||
//Blocks an attempt to connect before even creating our client datum thing.
|
//Blocks an attempt to connect before even creating our client datum thing.
|
||||||
|
|
||||||
//How many new ckey matches before we revert the stickyban to it's roundstart state
|
//How many new ckey matches before we revert the stickyban to it's roundstart state
|
||||||
//These are exclusive, so once it goes over one of these numbers, it reverts the ban
|
//These are exclusive, so once it goes over one of these numbers, it reverts the ban
|
||||||
#define STICKYBAN_MAX_MATCHES 20
|
#define STICKYBAN_MAX_MATCHES 20
|
||||||
#define STICKYBAN_MAX_EXISTING_USER_MATCHES 5 //ie, users who were connected before the ban triggered
|
#define STICKYBAN_MAX_EXISTING_USER_MATCHES 5 //ie, users who were connected before the ban triggered
|
||||||
#define STICKYBAN_MAX_ADMIN_MATCHES 2
|
#define STICKYBAN_MAX_ADMIN_MATCHES 2
|
||||||
|
|
||||||
/world/IsBanned(key,address,computer_id)
|
/world/IsBanned(key,address,computer_id)
|
||||||
if (!key || !address || !computer_id)
|
if (!key || !address || !computer_id)
|
||||||
log_access("Failed Login (invalid data): [key] [address]-[computer_id]")
|
log_access("Failed Login (invalid data): [key] [address]-[computer_id]")
|
||||||
return list("reason"="invalid login data", "desc"="Error: Could not check ban status, Please try again. Error message: Your computer provided invalid or blank information to the server on connection (byond username, IP, and Computer ID.) Provided information for reference: Username:'[key]' IP:'[address]' Computer ID:'[computer_id]'. (If you continue to get this error, please restart byond or contact byond support.)")
|
return list("reason"="invalid login data", "desc"="Error: Could not check ban status, Please try again. Error message: Your computer provided invalid or blank information to the server on connection (byond username, IP, and Computer ID.) Provided information for reference: Username:'[key]' IP:'[address]' Computer ID:'[computer_id]'. (If you continue to get this error, please restart byond or contact byond support.)")
|
||||||
|
|
||||||
if (text2num(computer_id) == 2147483647) //this cid causes stickybans to go haywire
|
if (text2num(computer_id) == 2147483647) //this cid causes stickybans to go haywire
|
||||||
log_access("Failed Login (invalid cid): [key] [address]-[computer_id]")
|
log_access("Failed Login (invalid cid): [key] [address]-[computer_id]")
|
||||||
return list("reason"="invalid login data", "desc"="Error: Could not check ban status, Please try again. Error message: Your computer provided an invalid Computer ID.)")
|
return list("reason"="invalid login data", "desc"="Error: Could not check ban status, Please try again. Error message: Your computer provided an invalid Computer ID.)")
|
||||||
var/admin = 0
|
var/admin = 0
|
||||||
var/ckey = ckey(key)
|
var/ckey = ckey(key)
|
||||||
if((ckey in GLOB.admin_datums) || (ckey in GLOB.deadmins))
|
if((ckey in GLOB.admin_datums) || (ckey in GLOB.deadmins))
|
||||||
admin = 1
|
admin = 1
|
||||||
|
|
||||||
//Whitelist
|
//Whitelist
|
||||||
if(config.usewhitelist)
|
if(config.usewhitelist)
|
||||||
if(!check_whitelist(ckey(key)))
|
if(!check_whitelist(ckey(key)))
|
||||||
if (admin)
|
if (admin)
|
||||||
log_admin("The admin [key] has been allowed to bypass the whitelist")
|
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>")
|
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>")
|
addclientmessage(ckey,"<span class='adminnotice'>You have been allowed to bypass the whitelist</span>")
|
||||||
else
|
else
|
||||||
log_access("Failed Login: [key] - Not on whitelist")
|
log_access("Failed Login: [key] - Not on whitelist")
|
||||||
return list("reason"="whitelist", "desc" = "\nReason: You are not on the white list for this server")
|
return list("reason"="whitelist", "desc" = "\nReason: You are not on the white list for this server")
|
||||||
|
|
||||||
//Guest Checking
|
//Guest Checking
|
||||||
if(IsGuestKey(key))
|
if(IsGuestKey(key))
|
||||||
if (!GLOB.guests_allowed)
|
if (!GLOB.guests_allowed)
|
||||||
log_access("Failed Login: [key] - Guests not allowed")
|
log_access("Failed Login: [key] - Guests not allowed")
|
||||||
return list("reason"="guest", "desc"="\nReason: Guests not allowed. Please sign in with a byond account.")
|
return list("reason"="guest", "desc"="\nReason: Guests not allowed. Please sign in with a byond account.")
|
||||||
if (config.panic_bunker && SSdbcore && SSdbcore.IsConnected())
|
if (config.panic_bunker && SSdbcore && SSdbcore.IsConnected())
|
||||||
log_access("Failed Login: [key] - Guests not allowed during panic bunker")
|
log_access("Failed Login: [key] - Guests not allowed during panic bunker")
|
||||||
return list("reason"="guest", "desc"="\nReason: Sorry but the server is currently not accepting connections from never before seen players or guests. If you have played on this server with a byond account before, please log in to the byond account you have played from.")
|
return list("reason"="guest", "desc"="\nReason: Sorry but the server is currently not accepting connections from never before seen players or guests. If you have played on this server with a byond account before, please log in to the byond account you have played from.")
|
||||||
|
|
||||||
//Population Cap Checking
|
//Population Cap Checking
|
||||||
if(config.extreme_popcap && living_player_count() >= config.extreme_popcap && !admin)
|
if(config.extreme_popcap && living_player_count() >= config.extreme_popcap && !admin)
|
||||||
log_access("Failed Login: [key] - Population cap reached")
|
log_access("Failed Login: [key] - Population cap reached")
|
||||||
return list("reason"="popcap", "desc"= "\nReason: [config.extreme_popcap_message]")
|
return list("reason"="popcap", "desc"= "\nReason: [config.extreme_popcap_message]")
|
||||||
|
|
||||||
if(config.ban_legacy_system)
|
if(config.ban_legacy_system)
|
||||||
|
|
||||||
//Ban Checking
|
//Ban Checking
|
||||||
. = CheckBan( ckey(key), computer_id, address )
|
. = CheckBan( ckey(key), computer_id, address )
|
||||||
if(.)
|
if(.)
|
||||||
if (admin)
|
if (admin)
|
||||||
log_admin("The admin [key] has been allowed to bypass a matching ban on [.["key"]]")
|
log_admin("The admin [key] has been allowed to bypass a matching ban on [.["key"]]")
|
||||||
message_admins("<span class='adminnotice'>The admin [key] has been allowed to bypass a matching ban on [.["key"]]</span>")
|
message_admins("<span class='adminnotice'>The admin [key] has been allowed to bypass a matching ban on [.["key"]]</span>")
|
||||||
addclientmessage(ckey,"<span class='adminnotice'>You have been allowed to bypass a matching ban on [.["key"]]</span>")
|
addclientmessage(ckey,"<span class='adminnotice'>You have been allowed to bypass a matching ban on [.["key"]]</span>")
|
||||||
else
|
else
|
||||||
log_access("Failed Login: [key] [computer_id] [address] - Banned [.["reason"]]")
|
log_access("Failed Login: [key] [computer_id] [address] - Banned [.["reason"]]")
|
||||||
return .
|
return .
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
var/ckeytext = ckey(key)
|
var/ckeytext = ckey(key)
|
||||||
|
|
||||||
if(!SSdbcore.Connect())
|
if(!SSdbcore.Connect())
|
||||||
log_world("Ban database connection failure. Key [ckeytext] not checked")
|
var/msg = "Ban database connection failure. Key [ckeytext] not checked"
|
||||||
GLOB.world_game_log << "Ban database connection failure. Key [ckeytext] not checked"
|
log_world(msg)
|
||||||
return
|
message_admins(msg)
|
||||||
|
return
|
||||||
var/ipquery = ""
|
|
||||||
var/cidquery = ""
|
var/ipquery = ""
|
||||||
if(address)
|
var/cidquery = ""
|
||||||
ipquery = " OR ip = INET_ATON('[address]') "
|
if(address)
|
||||||
|
ipquery = " OR ip = INET_ATON('[address]') "
|
||||||
if(computer_id)
|
|
||||||
cidquery = " OR computerid = '[computer_id]' "
|
if(computer_id)
|
||||||
|
cidquery = " OR computerid = '[computer_id]' "
|
||||||
|
|
||||||
var/datum/DBQuery/query_ban_check = SSdbcore.NewQuery("SELECT ckey, a_ckey, reason, expiration_time, duration, bantime, bantype FROM [format_table_name("ban")] WHERE (ckey = '[ckeytext]' [ipquery] [cidquery]) AND (bantype = 'PERMABAN' OR bantype = 'ADMIN_PERMABAN' OR ((bantype = 'TEMPBAN' OR bantype = 'ADMIN_TEMPBAN') AND expiration_time > Now())) AND isnull(unbanned)")
|
var/datum/DBQuery/query_ban_check = SSdbcore.NewQuery("SELECT ckey, a_ckey, reason, expiration_time, duration, bantime, bantype FROM [format_table_name("ban")] WHERE (ckey = '[ckeytext]' [ipquery] [cidquery]) AND (bantype = 'PERMABAN' OR bantype = 'ADMIN_PERMABAN' OR ((bantype = 'TEMPBAN' OR bantype = 'ADMIN_TEMPBAN') AND expiration_time > Now())) AND isnull(unbanned)")
|
||||||
if(!query_ban_check.Execute())
|
if(!query_ban_check.Execute())
|
||||||
return
|
return
|
||||||
while(query_ban_check.NextRow())
|
while(query_ban_check.NextRow())
|
||||||
var/pckey = query_ban_check.item[1]
|
var/pckey = query_ban_check.item[1]
|
||||||
var/ackey = query_ban_check.item[2]
|
var/ackey = query_ban_check.item[2]
|
||||||
var/reason = query_ban_check.item[3]
|
var/reason = query_ban_check.item[3]
|
||||||
var/expiration = query_ban_check.item[4]
|
var/expiration = query_ban_check.item[4]
|
||||||
var/duration = query_ban_check.item[5]
|
var/duration = query_ban_check.item[5]
|
||||||
var/bantime = query_ban_check.item[6]
|
var/bantime = query_ban_check.item[6]
|
||||||
var/bantype = query_ban_check.item[7]
|
var/bantype = query_ban_check.item[7]
|
||||||
if (bantype == "ADMIN_PERMABAN" || bantype == "ADMIN_TEMPBAN")
|
if (bantype == "ADMIN_PERMABAN" || bantype == "ADMIN_TEMPBAN")
|
||||||
//admin bans MUST match on ckey to prevent cid-spoofing attacks
|
//admin bans MUST match on ckey to prevent cid-spoofing attacks
|
||||||
// as well as dynamic ip abuse
|
// as well as dynamic ip abuse
|
||||||
if (pckey != ckey)
|
if (pckey != ckey)
|
||||||
continue
|
continue
|
||||||
if (admin)
|
if (admin)
|
||||||
if (bantype == "ADMIN_PERMABAN" || bantype == "ADMIN_TEMPBAN")
|
if (bantype == "ADMIN_PERMABAN" || bantype == "ADMIN_TEMPBAN")
|
||||||
log_admin("The admin [key] is admin banned, and has been disallowed access")
|
log_admin("The admin [key] is admin banned, and has been disallowed access")
|
||||||
message_admins("<span class='adminnotice'>The admin [key] is admin banned, and has been disallowed access</span>")
|
message_admins("<span class='adminnotice'>The admin [key] is admin banned, and has been disallowed access</span>")
|
||||||
else
|
else
|
||||||
log_admin("The admin [key] has been allowed to bypass a matching ban on [pckey]")
|
log_admin("The admin [key] has been allowed to bypass a matching ban on [pckey]")
|
||||||
message_admins("<span class='adminnotice'>The admin [key] has been allowed to bypass a matching ban on [pckey]</span>")
|
message_admins("<span class='adminnotice'>The admin [key] has been allowed to bypass a matching ban on [pckey]</span>")
|
||||||
addclientmessage(ckey,"<span class='adminnotice'>You have been allowed to bypass a matching ban on [pckey]</span>")
|
addclientmessage(ckey,"<span class='adminnotice'>You have been allowed to bypass a matching ban on [pckey]</span>")
|
||||||
continue
|
continue
|
||||||
var/expires = ""
|
var/expires = ""
|
||||||
if(text2num(duration) > 0)
|
if(text2num(duration) > 0)
|
||||||
expires = " The ban is for [duration] minutes and expires on [expiration] (server time)."
|
expires = " The ban is for [duration] minutes and expires on [expiration] (server time)."
|
||||||
else
|
else
|
||||||
expires = " The is a permanent ban."
|
expires = " The is a permanent ban."
|
||||||
|
|
||||||
var/desc = "\nReason: You, or another user of this computer or connection ([pckey]) is banned from playing here. The ban reason is:\n[reason]\nThis ban was applied by [ackey] on [bantime], [expires]"
|
var/desc = "\nReason: You, or another user of this computer or connection ([pckey]) is banned from playing here. The ban reason is:\n[reason]\nThis ban was applied by [ackey] on [bantime], [expires]"
|
||||||
|
|
||||||
. = list("reason"="[bantype]", "desc"="[desc]")
|
. = list("reason"="[bantype]", "desc"="[desc]")
|
||||||
|
|
||||||
|
|
||||||
log_access("Failed Login: [key] [computer_id] [address] - Banned [.["reason"]]")
|
log_access("Failed Login: [key] [computer_id] [address] - Banned [.["reason"]]")
|
||||||
return .
|
return .
|
||||||
|
|
||||||
var/list/ban = ..() //default pager ban stuff
|
var/list/ban = ..() //default pager ban stuff
|
||||||
if (ban)
|
if (ban)
|
||||||
var/bannedckey = "ERROR"
|
var/bannedckey = "ERROR"
|
||||||
if (ban["ckey"])
|
if (ban["ckey"])
|
||||||
bannedckey = ban["ckey"]
|
bannedckey = ban["ckey"]
|
||||||
|
|
||||||
var/newmatch = FALSE
|
var/newmatch = FALSE
|
||||||
var/client/C = GLOB.directory[ckey]
|
var/client/C = GLOB.directory[ckey]
|
||||||
var/cachedban = SSstickyban.cache[bannedckey]
|
var/cachedban = SSstickyban.cache[bannedckey]
|
||||||
|
|
||||||
//rogue ban in the process of being reverted.
|
//rogue ban in the process of being reverted.
|
||||||
if (cachedban && cachedban["reverting"])
|
if (cachedban && cachedban["reverting"])
|
||||||
return null
|
return null
|
||||||
|
|
||||||
if (cachedban && ckey != bannedckey)
|
if (cachedban && ckey != bannedckey)
|
||||||
newmatch = TRUE
|
newmatch = TRUE
|
||||||
if (cachedban["keys"])
|
if (cachedban["keys"])
|
||||||
if (cachedban["keys"][ckey])
|
if (cachedban["keys"][ckey])
|
||||||
newmatch = FALSE
|
newmatch = FALSE
|
||||||
if (cachedban["matches_this_round"][ckey])
|
if (cachedban["matches_this_round"][ckey])
|
||||||
newmatch = FALSE
|
newmatch = FALSE
|
||||||
|
|
||||||
if (newmatch && cachedban)
|
if (newmatch && cachedban)
|
||||||
var/list/newmatches = cachedban["matches_this_round"]
|
var/list/newmatches = cachedban["matches_this_round"]
|
||||||
var/list/newmatches_connected = cachedban["existing_user_matches_this_round"]
|
var/list/newmatches_connected = cachedban["existing_user_matches_this_round"]
|
||||||
var/list/newmatches_admin = cachedban["admin_matches_this_round"]
|
var/list/newmatches_admin = cachedban["admin_matches_this_round"]
|
||||||
|
|
||||||
newmatches[ckey] = ckey
|
newmatches[ckey] = ckey
|
||||||
if (C)
|
if (C)
|
||||||
newmatches_connected[ckey] = ckey
|
newmatches_connected[ckey] = ckey
|
||||||
if (admin)
|
if (admin)
|
||||||
newmatches_admin[ckey] = ckey
|
newmatches_admin[ckey] = ckey
|
||||||
|
|
||||||
if (\
|
if (\
|
||||||
newmatches.len > STICKYBAN_MAX_MATCHES || \
|
newmatches.len > STICKYBAN_MAX_MATCHES || \
|
||||||
newmatches_connected.len > STICKYBAN_MAX_EXISTING_USER_MATCHES || \
|
newmatches_connected.len > STICKYBAN_MAX_EXISTING_USER_MATCHES || \
|
||||||
newmatches_admin.len > STICKYBAN_MAX_ADMIN_MATCHES \
|
newmatches_admin.len > STICKYBAN_MAX_ADMIN_MATCHES \
|
||||||
)
|
)
|
||||||
if (cachedban["reverting"])
|
if (cachedban["reverting"])
|
||||||
return null
|
return null
|
||||||
cachedban["reverting"] = TRUE
|
cachedban["reverting"] = TRUE
|
||||||
|
|
||||||
world.SetConfig("ban", bannedckey, null)
|
world.SetConfig("ban", bannedckey, null)
|
||||||
|
|
||||||
log_game("Stickyban on [bannedckey] detected as rogue, reverting to it's roundstart state")
|
log_game("Stickyban on [bannedckey] detected as rogue, reverting to it's roundstart state")
|
||||||
message_admins("Stickyban on [bannedckey] detected as rogue, reverting to it's roundstart state")
|
message_admins("Stickyban on [bannedckey] detected as rogue, reverting to it's roundstart state")
|
||||||
//do not convert to timer.
|
//do not convert to timer.
|
||||||
spawn (5)
|
spawn (5)
|
||||||
world.SetConfig("ban", bannedckey, null)
|
world.SetConfig("ban", bannedckey, null)
|
||||||
sleep(1)
|
sleep(1)
|
||||||
world.SetConfig("ban", bannedckey, null)
|
world.SetConfig("ban", bannedckey, null)
|
||||||
cachedban["matches_this_round"] = list()
|
cachedban["matches_this_round"] = list()
|
||||||
cachedban["existing_user_matches_this_round"] = list()
|
cachedban["existing_user_matches_this_round"] = list()
|
||||||
cachedban["admin_matches_this_round"] = list()
|
cachedban["admin_matches_this_round"] = list()
|
||||||
cachedban -= "reverting"
|
cachedban -= "reverting"
|
||||||
world.SetConfig("ban", bannedckey, list2stickyban(cachedban))
|
world.SetConfig("ban", bannedckey, list2stickyban(cachedban))
|
||||||
return null
|
return null
|
||||||
|
|
||||||
//byond will not trigger isbanned() for "global" host bans,
|
//byond will not trigger isbanned() for "global" host bans,
|
||||||
//ie, ones where the "apply to this game only" checkbox is not checked (defaults to not checked)
|
//ie, ones where the "apply to this game only" checkbox is not checked (defaults to not checked)
|
||||||
//So it's safe to let admins walk thru host/sticky bans here
|
//So it's safe to let admins walk thru host/sticky bans here
|
||||||
if (admin)
|
if (admin)
|
||||||
log_admin("The admin [key] has been allowed to bypass a matching host/sticky ban on [bannedckey]")
|
log_admin("The admin [key] has been allowed to bypass a matching host/sticky ban on [bannedckey]")
|
||||||
message_admins("<span class='adminnotice'>The admin [key] has been allowed to bypass a matching host/sticky ban on [bannedckey]</span>")
|
message_admins("<span class='adminnotice'>The admin [key] has been allowed to bypass a matching host/sticky ban on [bannedckey]</span>")
|
||||||
addclientmessage(ckey,"<span class='adminnotice'>You have been allowed to bypass a matching host/sticky ban on [bannedckey]</span>")
|
addclientmessage(ckey,"<span class='adminnotice'>You have been allowed to bypass a matching host/sticky ban on [bannedckey]</span>")
|
||||||
return null
|
return null
|
||||||
|
|
||||||
if (C) //user is already connected!.
|
if (C) //user is already connected!.
|
||||||
to_chat(C, "You are about to get disconnected for matching a sticky ban after you connected. If this turns out to be the ban evasion detection system going haywire, we will automatically detect this and revert the matches. if you feel that this is the case, please wait EXACTLY 6 seconds then reconnect using file -> reconnect to see if the match was reversed.")
|
to_chat(C, "You are about to get disconnected for matching a sticky ban after you connected. If this turns out to be the ban evasion detection system going haywire, we will automatically detect this and revert the matches. if you feel that this is the case, please wait EXACTLY 6 seconds then reconnect using file -> reconnect to see if the match was reversed.")
|
||||||
|
|
||||||
var/desc = "\nReason:(StickyBan) You, or another user of this computer or connection ([bannedckey]) is banned from playing here. The ban reason is:\n[ban["message"]]\nThis ban was applied by [ban["admin"]]\nThis is a BanEvasion Detection System ban, if you think this ban is a mistake, please wait EXACTLY 6 seconds, then try again before filing an appeal.\n"
|
var/desc = "\nReason:(StickyBan) You, or another user of this computer or connection ([bannedckey]) is banned from playing here. The ban reason is:\n[ban["message"]]\nThis ban was applied by [ban["admin"]]\nThis is a BanEvasion Detection System ban, if you think this ban is a mistake, please wait EXACTLY 6 seconds, then try again before filing an appeal.\n"
|
||||||
. = list("reason" = "Stickyban", "desc" = desc)
|
. = list("reason" = "Stickyban", "desc" = desc)
|
||||||
log_access("Failed Login: [key] [computer_id] [address] - StickyBanned [ban["message"]] Target Username: [bannedckey] Placed by [ban["admin"]]")
|
log_access("Failed Login: [key] [computer_id] [address] - StickyBanned [ban["message"]] Target Username: [bannedckey] Placed by [ban["admin"]]")
|
||||||
|
|
||||||
return .
|
return .
|
||||||
|
|
||||||
|
|
||||||
#undef STICKYBAN_MAX_MATCHES
|
#undef STICKYBAN_MAX_MATCHES
|
||||||
#undef STICKYBAN_MAX_EXISTING_USER_MATCHES
|
#undef STICKYBAN_MAX_EXISTING_USER_MATCHES
|
||||||
#undef STICKYBAN_MAX_ADMIN_MATCHES
|
#undef STICKYBAN_MAX_ADMIN_MATCHES
|
||||||
|
|||||||
Reference in New Issue
Block a user