Cleans up the TODOs I left all over the codebase (#16443)

* Removes command_name() proc

* Removes GLOB.teleportlocs + GLOB.ghostteleportlocs

* Clean up IPIntel

* Tweaks karma logging

* Tweaks time
This commit is contained in:
AffectedArc07
2021-07-28 13:45:18 -04:00
committed by GitHub
parent fba7585b4e
commit e46f67810a
32 changed files with 448 additions and 327 deletions
+18 -1
View File
@@ -35,7 +35,7 @@
return list("reason"="guest", "desc"="\nReason: Guests not allowed. Please sign in with a BYOND account.")
//check if the IP address is a known proxy/vpn, and the user is not whitelisted
if(check_ipintel && GLOB.configuration.ipintel.contact_email && GLOB.configuration.ipintel.whitelist_mode && ipintel_is_banned(key, address))
if(check_ipintel && GLOB.configuration.ipintel.contact_email && GLOB.configuration.ipintel.whitelist_mode && SSipintel.ipintel_is_banned(key, address))
log_adminwarn("Failed Login: [key] [computer_id] [address] - Proxy/VPN")
var/mistakemessage = ""
if(GLOB.configuration.url.banappeals_url)
@@ -87,6 +87,23 @@
qdel(verify_query)
if(SSdbcore.IsConnected())
// If we have a DB, see if the player has been seen before
var/datum/db_query/exist_query = SSdbcore.NewQuery("SELECT ckey FROM player WHERE ckey=:ckey", list(
"ckey" = ckey
))
// If we didnt execute, skip this part
if(!exist_query.warn_execute())
qdel(exist_query)
else
if(!exist_query.NextRow()) // If there isnt a row, they aint been seen before
if(GLOB.panic_bunker_enabled)
qdel(exist_query)
var/threshold = GLOB.configuration.general.panic_bunker_threshold
return list("reason" = "panic bunker", "desc" = "Server is not accepting connections from never-before-seen players until player count is less than [threshold]. Please try again later.")
qdel(exist_query)
if(!GLOB.configuration.general.use_database_bans)
//Ban Checking
. = CheckBan(ckey(key), computer_id, address)
+1 -1
View File
@@ -315,7 +315,7 @@ GLOBAL_VAR_INIT(nologevent, 0)
return
var/key = stripped_input(usr, "Enter ckey to add/remove, or leave blank to cancel:", "VPN Whitelist add/remove", max_length=32)
if(key)
vpn_whitelist_panel(key)
SSipintel.vpn_whitelist_panel(key)
/datum/admins/proc/Jobbans()
if(!check_rights(R_BAN))
-250
View File
@@ -1,250 +0,0 @@
// AA TODO: Make these procs part of SSipintel
/datum/ipintel
var/ip
var/intel = 0
var/cache = FALSE
var/cacheminutesago = 0
var/cachedate = ""
var/cacherealtime = 0
/datum/ipintel/New()
cachedate = SQLtime()
cacherealtime = world.realtime
/datum/ipintel/proc/is_valid()
. = FALSE
if(intel < 0)
return
if(intel <= GLOB.configuration.ipintel.bad_rating)
if(world.realtime < cacherealtime + (GLOB.configuration.ipintel.hours_save_good HOURS))
return TRUE
else
if(world.realtime < cacherealtime + (GLOB.configuration.ipintel.hours_save_bad HOURS))
return TRUE
/proc/get_ip_intel(ip, bypasscache = FALSE, updatecache = TRUE)
var/datum/ipintel/res = new()
res.ip = ip
. = res
if(!ip || !GLOB.configuration.ipintel.contact_email || !GLOB.configuration.ipintel.enabled || !SSipintel.enabled)
return
if(!bypasscache)
var/datum/ipintel/cachedintel = SSipintel.cache[ip]
if(cachedintel && cachedintel.is_valid())
cachedintel.cache = TRUE
return cachedintel
if(SSdbcore.IsConnected())
var/datum/db_query/query_get_ip_intel = SSdbcore.NewQuery({"
SELECT date, intel, TIMESTAMPDIFF(MINUTE,date,NOW())
FROM ipintel
WHERE
ip = INET_ATON(:ip)
AND ((
intel < :rating_bad
AND
date + INTERVAL :save_good HOUR > NOW()
) OR (
intel >= :rating_bad
AND
date + INTERVAL :save_bad HOUR > NOW()
))
"}, list(
"ip" = ip,
"rating_bad" = GLOB.configuration.ipintel.bad_rating,
"save_good" = GLOB.configuration.ipintel.hours_save_good,
"save_bad" = GLOB.configuration.ipintel.hours_save_bad,
))
if(!query_get_ip_intel.warn_execute())
qdel(query_get_ip_intel)
return
if(query_get_ip_intel.NextRow())
res.cache = TRUE
res.cachedate = query_get_ip_intel.item[1]
res.intel = text2num(query_get_ip_intel.item[2])
res.cacheminutesago = text2num(query_get_ip_intel.item[3])
res.cacherealtime = world.realtime - (text2num(query_get_ip_intel.item[3])*10*60)
SSipintel.cache[ip] = res
qdel(query_get_ip_intel)
return
qdel(query_get_ip_intel)
res.intel = ip_intel_query(ip)
if(updatecache && res.intel >= 0)
SSipintel.cache[ip] = res
if(SSdbcore.IsConnected())
var/datum/db_query/query_add_ip_intel = SSdbcore.NewQuery({"
INSERT INTO ipintel (ip, intel) VALUES (INET_ATON(:ip), :intel)
ON DUPLICATE KEY UPDATE intel = VALUES(intel), date = NOW()"},
list(
"ip" = ip,
"intel" = res.intel
)
)
query_add_ip_intel.warn_execute()
qdel(query_add_ip_intel)
/proc/ip_intel_query(ip, retryed=0)
. = -1 //default
if(!ip)
return
if(SSipintel.throttle > world.timeofday)
return
if(!SSipintel.enabled)
return
// Do not refactor this to use SShttp, because that requires the subsystem to be firing for requests to be made, and this will be triggered before the MC has finished loading
var/list/http[] = world.Export("http://[GLOB.configuration.ipintel.ipintel_domain]/check.php?ip=[ip]&contact=[GLOB.configuration.ipintel.contact_email]&format=json&flags=b")
if(http)
var/status = text2num(http["STATUS"])
if(status == 200)
var/response = json_decode(file2text(http["CONTENT"]))
if(response)
if(response["status"] == "success")
var/intelnum = text2num(response["result"])
if(isnum(intelnum))
return text2num(response["result"])
else
ipintel_handle_error("Bad intel from server: [response["result"]].", ip, retryed)
if(!retryed)
sleep(25)
return .(ip, 1)
else
ipintel_handle_error("Bad response from server: [response["status"]].", ip, retryed)
if(!retryed)
sleep(25)
return .(ip, 1)
else if(status == 429)
ipintel_handle_error("Error #429: We have exceeded the rate limit.", ip, 1)
return
else
ipintel_handle_error("Unknown status code: [status].", ip, retryed)
if(!retryed)
sleep(25)
return .(ip, 1)
else
ipintel_handle_error("Unable to connect to API.", ip, retryed)
if(!retryed)
sleep(25)
return .(ip, 1)
/proc/ipintel_handle_error(error, ip, retryed)
if(retryed)
SSipintel.errors++
error += " Could not check [ip]. Disabling IPINTEL for [SSipintel.errors] minute[( SSipintel.errors == 1 ? "" : "s" )]"
SSipintel.throttle = world.timeofday + (2 * SSipintel.errors MINUTES)
else
error += " Attempting retry on [ip]."
log_ipintel(error)
/proc/log_ipintel(text)
log_game("IPINTEL: [text]")
log_debug("IPINTEL: [text]")
/proc/ipintel_is_banned(t_ckey, t_ip)
if(!GLOB.configuration.ipintel.contact_email)
return FALSE
if(!GLOB.configuration.ipintel.enabled)
return FALSE
if(!GLOB.configuration.ipintel.whitelist_mode)
return FALSE
if(!SSdbcore.IsConnected())
return FALSE
if(!ipintel_badip_check(t_ip))
return FALSE
if(vpn_whitelist_check(t_ckey))
return FALSE
return TRUE
/proc/ipintel_badip_check(target_ip)
var/rating_bad = GLOB.configuration.ipintel.bad_rating
if(!rating_bad)
log_debug("ipintel_badip_check reports misconfigured rating_bad directive")
return FALSE
var/valid_hours = GLOB.configuration.ipintel.hours_save_bad
if(!valid_hours)
log_debug("ipintel_badip_check reports misconfigured ipintel_save_bad directive")
return FALSE
var/datum/db_query/query_get_ip_intel = SSdbcore.NewQuery({"
SELECT * FROM ipintel WHERE ip = INET_ATON(:target_ip)
AND intel >= :rating_bad AND (date + INTERVAL :valid_hours HOUR) > NOW()"},
list(
"target_ip" = target_ip,
"rating_bad" = rating_bad,
"valid_hours" = valid_hours
)
)
if(!query_get_ip_intel.warn_execute())
log_debug("ipintel_badip_check reports failed query execution")
qdel(query_get_ip_intel)
return FALSE
if(!query_get_ip_intel.NextRow())
qdel(query_get_ip_intel)
return FALSE
qdel(query_get_ip_intel)
return TRUE
/proc/vpn_whitelist_check(target_ckey)
if(!GLOB.configuration.ipintel.whitelist_mode)
return FALSE
var/datum/db_query/query_whitelist_check = SSdbcore.NewQuery("SELECT * FROM vpn_whitelist WHERE ckey=:ckey", list(
"ckey" = target_ckey
))
if(!query_whitelist_check.warn_execute())
qdel(query_whitelist_check)
return FALSE
if(query_whitelist_check.NextRow())
qdel(query_whitelist_check)
return TRUE // At least one row in the whitelist names their ckey. That means they are whitelisted.
qdel(query_whitelist_check)
return FALSE
/proc/vpn_whitelist_add(target_ckey)
var/reason_string = input(usr, "Enter link to the URL of their whitelist request on the forum.","Reason required") as message|null
if(!reason_string)
return FALSE
var/datum/db_query/query_whitelist_add = SSdbcore.NewQuery("INSERT INTO vpn_whitelist (ckey,reason) VALUES (:targetckey, :reason)", list(
"targetckey" = target_ckey,
"reason" = reason_string
))
if(!query_whitelist_add.warn_execute())
qdel(query_whitelist_add)
return FALSE
qdel(query_whitelist_add)
return TRUE
/proc/vpn_whitelist_remove(target_ckey)
var/datum/db_query/query_whitelist_remove = SSdbcore.NewQuery("DELETE FROM vpn_whitelist WHERE ckey=:targetckey", list(
"targetckey" = target_ckey
))
if(!query_whitelist_remove.warn_execute())
qdel(query_whitelist_remove)
return FALSE
qdel(query_whitelist_remove)
return TRUE
/proc/vpn_whitelist_panel(target_ckey as text)
if(!check_rights(R_ADMIN))
return
if(!target_ckey)
return
var/is_already_whitelisted = vpn_whitelist_check(target_ckey)
if(is_already_whitelisted)
var/confirm = alert("[target_ckey] is already whitelisted. Remove them?", "Confirm Removal", "No", "Yes")
if(!confirm || confirm != "Yes")
to_chat(usr, "VPN whitelist alteration cancelled.")
return
else if(vpn_whitelist_remove(target_ckey))
to_chat(usr, "[target_ckey] was removed from the VPN whitelist.")
else
to_chat(usr, "VPN whitelist unchanged.")
else
if(vpn_whitelist_add(target_ckey))
to_chat(usr, "[target_ckey] was added to the VPN whitelist.")
else
to_chat(usr, "VPN whitelist unchanged.")
+3 -3
View File
@@ -2509,7 +2509,7 @@
if("Central Command")
stamptype = "icon"
stampvalue = "cent"
sendername = command_name()
sendername = "NAS Trurl"
if("Syndicate")
stamptype = "icon"
stampvalue = "syndicate"
@@ -3213,7 +3213,7 @@
if(!SSshuttle.toggleShuttle("ferry","ferry_home","ferry_away"))
message_admins("[key_name_admin(usr)] moved the centcom ferry")
log_admin("[key_name(usr)] moved the centcom ferry")
if("gammashuttle")
SSblackbox.record_feedback("tally", "admin_secrets_fun_used", 1, "Send Gamma Armory")
message_admins("[key_name_admin(usr)] moved the gamma armory")
@@ -3378,7 +3378,7 @@
if(!newname)
return
G.name = newname
var/description = input("Enter [command_name()] message contents:") as message|null
var/description = input("Enter NAS Trurl message contents:") as message|null
if(!description)
return
G.report_message = description
-1
View File
@@ -56,7 +56,6 @@
var/global/obj/screen/click_catcher/void
var/karma = 0
var/karma_spent = 0
var/karma_tab = 0
+5 -12
View File
@@ -563,15 +563,6 @@
INVOKE_ASYNC(src, /client/.proc/get_byond_account_date, FALSE) // Async to avoid other procs in the client chain being delayed by a web request
else
//New player!! Need to insert all the stuff
// Check new peeps for panic bunker
// AA TODO: Move this to world.IsBanned()
if(GLOB.panic_bunker_enabled)
var/threshold = GLOB.configuration.general.panic_bunker_threshold
src << "Server is not accepting connections from never-before-seen players until player count is less than [threshold]. Please try again later."
qdel(src)
return // Dont insert or they can just go in again
var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO player (id, ckey, firstseen, lastseen, ip, computerid, lastadminrank) VALUES (null, :ckey, Now(), Now(), :ip, :cid, :rank)", list(
"ckey" = ckey,
"ip" = address,
@@ -601,11 +592,11 @@
log_debug("check_ip_intel: skip check for player [key_name_admin(src)] connecting from localhost.")
return
if(vpn_whitelist_check(ckey))
if(SSipintel.vpn_whitelist_check(ckey))
log_debug("check_ip_intel: skip check for player [key_name_admin(src)] [address] on whitelist.")
return
var/datum/ipintel/res = get_ip_intel(address)
var/datum/ipintel/res = SSipintel.get_ip_intel(address)
ip_intel = res.intel
verify_ip_intel()
@@ -613,7 +604,9 @@
if(ip_intel >= GLOB.configuration.ipintel.bad_rating)
var/detailsurl = GLOB.configuration.ipintel.details_url ? "(<a href='[GLOB.configuration.ipintel.details_url][address]'>IP Info</a>)" : ""
if(GLOB.configuration.ipintel.whitelist_mode)
// AA TODO: move this check to world.IsBanned()
// Do not move this to isBanned(). This may sound weird, but:
// This needs to happen after their account is put into the DB
// This way, admins can then note people
spawn(40) // This is necessary because without it, they won't see the message, and addtimer cannot be used because the timer system may not have initialized yet
message_admins("<span class='adminnotice'>IPIntel: [key_name_admin(src)] on IP [address] was rejected. [detailsurl]</span>")
var/blockmsg = "<B>Error: proxy/VPN detected. Proxy/VPN use is not allowed here. Deactivate it before you reconnect.</B>"
+2 -2
View File
@@ -21,7 +21,7 @@
var/mob/living/simple_animal/SA = pick(potential)
var/mob/SG = pick(candidates)
var/sentience_report = "<font size=3><b>[command_name()] Medium-Priority Update</b></font>"
var/sentience_report = "<font size=3><b>NAS Trurl Medium-Priority Update</b></font>"
var/data = pick("scans from our long-range sensors", "our sophisticated probabilistic models", "our omnipotence", "the communications traffic on your station", "energy emissions we detected", "\[REDACTED\]", "Steve")
var/pets = pick("animals", "pets", "simple animals", "lesser lifeforms", "\[REDACTED\]")
@@ -40,7 +40,7 @@
SA.health = SA.maxHealth
SA.del_on_death = FALSE
greet_sentient(SA)
print_command_report(sentience_report, "[command_name()] Update", FALSE)
print_command_report(sentience_report, "NAS Trurl Update", FALSE)
/datum/event/sentience/proc/greet_sentient(mob/living/carbon/human/M)
to_chat(M, "<span class='userdanger'>Hello world!</span>")
+2 -4
View File
@@ -160,21 +160,19 @@ GLOBAL_LIST_EMPTY(karma_spenders)
if(!can_give_karma_to_mob(M))
return // Check again, just in case things changed while the alert box was up
M.client.karma++
to_chat(usr, "Good karma spent on [M.name].")
client.karma_spent = TRUE
GLOB.karma_spenders += ckey
var/special_role = "None"
var/assigned_role = "None"
var/karma_diary = file("[GLOB.log_directory]/karma.log")
if(M.mind)
if(M.mind.special_role)
special_role = M.mind.special_role
if(M.mind.assigned_role)
assigned_role = M.mind.assigned_role
// AA TODO: Make this use proper RUSTG logging. Why is this a normal file write these are so expensive aaaaaaaaa
karma_diary << "[M.name] ([M.key]) [assigned_role]/[special_role]: [M.client.karma] - [time2text(world.timeofday, "hh:mm:ss")] given by [key]"
rustg_log_write("[GLOB.log_directory]/karma.log", "Karma awarded to [M.name] ([M.key]) (Role: [assigned_role] | Special: [special_role]) - Awarded by [ckey]")
sql_report_karma(src, M)
+1 -1
View File
@@ -362,7 +362,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
to_chat(usr, "Not when you're not dead!")
return
var/datum/async_input/A = input_autocomplete_async(usr, "Area to jump to: ", GLOB.ghostteleportlocs)
var/datum/async_input/A = input_autocomplete_async(usr, "Area to jump to: ", SSmapping.ghostteleportlocs)
A.on_close(CALLBACK(src, .proc/teleport))
/mob/dead/observer/proc/teleport(area/thearea)
@@ -81,8 +81,8 @@
pixel_y = 8
if(is_type_in_typecache(get_area(loc), invalid_area_typecache))
var/area = pick(GLOB.teleportlocs)
var/area/tp = GLOB.teleportlocs[area]
var/area = pick(SSmapping.teleportlocs)
var/area/tp = SSmapping.teleportlocs[area]
forceMove(pick(get_area_turfs(tp.type)))
if((!current_victim && !admincluwne) || QDELETED(current_victim))
+2 -1
View File
@@ -1009,7 +1009,8 @@ GLOBAL_LIST_INIT(slot_equipment_priority, list( \
// this function displays the station time in the status panel
/mob/proc/show_stat_station_time()
stat(null, "Round Time: [worldtime2text()]") // AA TODO: Make this do "Game Time" and "Round Time" with the ROUND_TIME macro
stat(null, "Server Uptime: [worldtime2text()]")
stat(null, "Round Time: [ROUND_TIME ? time2text(ROUND_TIME, "hh:mm:ss") : "N/A"]")
stat(null, "Station Time: [station_time_timestamp()]")
// this function displays the shuttles ETA in the status panel if the shuttle has been called
+2 -2
View File
@@ -33,8 +33,8 @@
/obj/item/assault_pod/attack_self(mob/living/user)
var/target_area
target_area = input("Area to land", "Select a Landing Zone", target_area) in GLOB.teleportlocs
var/area/picked_area = GLOB.teleportlocs[target_area]
target_area = input("Area to land", "Select a Landing Zone", target_area) in SSmapping.teleportlocs
var/area/picked_area = SSmapping.teleportlocs[target_area]
if(!src || QDELETED(src))
return
+1 -1
View File
@@ -311,7 +311,7 @@
var/packagesAmt = SSshuttle.shoppinglist.len + ((errors & MANIFEST_ERROR_COUNT) ? rand(1,2) : 0)
slip.name = "Shipping Manifest - '[object.name]' for [orderedby]"
slip.info = "<h3>[command_name()] Shipping Manifest</h3><hr><br>"
slip.info = "<h3>NAS Trurl Shipping Manifest</h3><hr><br>"
slip.info +="Order: #[ordernum]<br>"
slip.info +="Destination: [stationName]<br>"
slip.info +="Requested By: [orderedby]<br>"
+1 -1
View File
@@ -352,7 +352,7 @@
var/list/options = gps_locators
if(area_aim)
options += target_all_areas ? GLOB.ghostteleportlocs : GLOB.teleportlocs
options += target_all_areas ? SSmapping.ghostteleportlocs : SSmapping.teleportlocs
var/V = input(user,"Select target", "Select target",null) in options|null
target = options[V]
+1 -1
View File
@@ -37,7 +37,7 @@ GLOBAL_DATUM_INIT(centcomm_store, /datum/store, new())
return 0
mind.initial_account.money -= amount
var/datum/transaction/T = new()
T.target_name = "[command_name()] Merchandising"
T.target_name = "NAS Trurl Merchandising"
T.purpose = "Purchase of [item.name]"
T.amount = -amount
T.date = GLOB.current_date_string