mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2026-08-22 04:36:53 +01:00
Updates Part Eleven
This commit is contained in:
@@ -11,6 +11,7 @@ var/global/datum/ntnet/ntnet_global = new()
|
||||
var/list/chat_channels = list()
|
||||
var/list/fileservers = list()
|
||||
var/list/email_accounts = list() // I guess we won't have more than 999 email accounts active at once in single round, so this will do until Servers are implemented someday.
|
||||
var/list/banned_nids = list()
|
||||
// Amount of logs the system tries to keep in memory. Keep below 999 to prevent byond from acting weirdly.
|
||||
// High values make displaying logs much laggier.
|
||||
var/setting_maxlogcount = 100
|
||||
@@ -60,6 +61,16 @@ var/global/datum/ntnet/ntnet_global = new()
|
||||
else
|
||||
break
|
||||
|
||||
/datum/ntnet/proc/check_banned(var/NID)
|
||||
if(!relays || !relays.len)
|
||||
return FALSE
|
||||
|
||||
for(var/obj/machinery/ntnet_relay/R in relays)
|
||||
if(R.operable())
|
||||
return (NID in banned_nids)
|
||||
|
||||
return FALSE
|
||||
|
||||
// Checks whether NTNet operates. If parameter is passed checks whether specific function is enabled.
|
||||
/datum/ntnet/proc/check_function(var/specific_action = 0)
|
||||
if(!relays || !relays.len) // No relays found. NTNet is down
|
||||
|
||||
@@ -81,10 +81,16 @@
|
||||
dos_failure = 0
|
||||
update_icon()
|
||||
ntnet_global.add_log("Quantum relay manually restarted from overload recovery mode to normal operation mode.")
|
||||
return 1
|
||||
else if(href_list["toggle"])
|
||||
enabled = !enabled
|
||||
ntnet_global.add_log("Quantum relay manually [enabled ? "enabled" : "disabled"].")
|
||||
update_icon()
|
||||
return 1
|
||||
else if(href_list["purge"])
|
||||
ntnet_global.banned_nids.Cut()
|
||||
ntnet_global.add_log("Manual override: Network blacklist cleared.")
|
||||
return 1
|
||||
|
||||
/obj/machinery/ntnet_relay/New()
|
||||
uid = gl_uid
|
||||
|
||||
@@ -122,15 +122,18 @@
|
||||
if(tesla_link && tesla_link.enabled && apc_powered)
|
||||
data["PC_apclinkicon"] = "charging.gif"
|
||||
|
||||
switch(get_ntnet_status())
|
||||
if(0)
|
||||
data["PC_ntneticon"] = "sig_none.gif"
|
||||
if(1)
|
||||
data["PC_ntneticon"] = "sig_low.gif"
|
||||
if(2)
|
||||
data["PC_ntneticon"] = "sig_high.gif"
|
||||
if(3)
|
||||
data["PC_ntneticon"] = "sig_lan.gif"
|
||||
if(network_card && network_card.is_banned())
|
||||
data["PC_ntneticon"] = "sig_warning.gif"
|
||||
else
|
||||
switch(get_ntnet_status())
|
||||
if(0)
|
||||
data["PC_ntneticon"] = "sig_none.gif"
|
||||
if(1)
|
||||
data["PC_ntneticon"] = "sig_low.gif"
|
||||
if(2)
|
||||
data["PC_ntneticon"] = "sig_high.gif"
|
||||
if(3)
|
||||
data["PC_ntneticon"] = "sig_lan.gif"
|
||||
|
||||
var/list/program_headers = list()
|
||||
for(var/datum/computer_file/program/P in idle_threads)
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/datum/computer_file/program/access_decrypter
|
||||
filename = "nt_accrypt"
|
||||
filedesc = "NTNet Access Decrypter"
|
||||
program_icon_state = "hostile"
|
||||
program_key_state = "security_key"
|
||||
program_menu_icon = "unlocked"
|
||||
extended_desc = "This highly advanced script can very slowly decrypt operational codes used in almost any network. These codes can be downloaded to an ID card to expand the available access. The system administrator will probably notice this."
|
||||
size = 34
|
||||
requires_ntnet = 1
|
||||
available_on_ntnet = 0
|
||||
available_on_syndinet = 1
|
||||
nanomodule_path = /datum/nano_module/program/access_decrypter/
|
||||
var/message = ""
|
||||
var/running = FALSE
|
||||
var/progress = 0
|
||||
var/target_progress = 300
|
||||
|
||||
/datum/computer_file/program/access_decrypter/kill_program(var/forced)
|
||||
reset()
|
||||
..(forced)
|
||||
|
||||
/datum/computer_file/program/access_decrypter/proc/reset()
|
||||
running = FALSE
|
||||
message = ""
|
||||
progress = 0
|
||||
|
||||
/datum/computer_file/program/access_decrypter/process_tick()
|
||||
. = ..()
|
||||
if(!running)
|
||||
return
|
||||
var/obj/item/weapon/computer_hardware/processor_unit/CPU = computer.processor_unit
|
||||
var/obj/item/weapon/computer_hardware/card_slot/RFID = computer.card_slot
|
||||
if(!istype(CPU) || !CPU.check_functionality() || !istype(RFID) || !RFID.check_functionality())
|
||||
message = "A fatal hardware error has been detected."
|
||||
return
|
||||
if(!istype(RFID.stored_card))
|
||||
message = "RFID card has been removed from the device. Operation aborted."
|
||||
return
|
||||
|
||||
progress += CPU.max_idle_programs
|
||||
if(progress >= target_progress)
|
||||
reset()
|
||||
var/datum/access/A = get_access_by_id(pick(get_all_station_access()))
|
||||
RFID.stored_card.access |= A.id
|
||||
if(ntnet_global.intrusion_detection_enabled)
|
||||
ntnet_global.add_log("IDS WARNING - Unauthorised access to primary keycode database from device: [computer.network_card.get_network_tag()] - downloaded access codes for: [A.desc].")
|
||||
ntnet_global.intrusion_detection_alarm = 1
|
||||
message = "Successfully decrypted and saved operational key codes. Downloaded access codes for: [A.desc]"
|
||||
|
||||
/datum/computer_file/program/access_decrypter/Topic(href, href_list)
|
||||
if(..())
|
||||
return 1
|
||||
if(href_list["PRG_reset"])
|
||||
reset()
|
||||
return 1
|
||||
if(href_list["PRG_execute"])
|
||||
if(running)
|
||||
return 1
|
||||
var/obj/item/weapon/computer_hardware/processor_unit/CPU = computer.processor_unit
|
||||
var/obj/item/weapon/computer_hardware/card_slot/RFID = computer.card_slot
|
||||
if(!istype(CPU) || !CPU.check_functionality() || !istype(RFID) || !RFID.check_functionality())
|
||||
message = "A fatal hardware error has been detected."
|
||||
return
|
||||
if(!istype(RFID.stored_card))
|
||||
message = "RFID card is not present in the device. Operation aborted."
|
||||
return
|
||||
running = TRUE
|
||||
if(ntnet_global.intrusion_detection_enabled)
|
||||
ntnet_global.add_log("IDS WARNING - Unauthorised access attempt to primary keycode database from device: [computer.network_card.get_network_tag()]")
|
||||
ntnet_global.intrusion_detection_alarm = 1
|
||||
return 1
|
||||
|
||||
/datum/nano_module/program/access_decrypter
|
||||
name = "NTNet Access Decrypter"
|
||||
|
||||
/datum/nano_module/program/access_decrypter/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = GLOB.default_state)
|
||||
if(!ntnet_global)
|
||||
return
|
||||
var/datum/computer_file/program/access_decrypter/PRG = program
|
||||
var/list/data = list()
|
||||
if(!istype(PRG))
|
||||
return
|
||||
data = PRG.get_header_data()
|
||||
|
||||
if(PRG.message)
|
||||
data["message"] = PRG.message
|
||||
else if(PRG.running)
|
||||
data["running"] = 1
|
||||
data["rate"] = PRG.computer.processor_unit.max_idle_programs
|
||||
|
||||
// Stolen from DOS traffic generator, generates strings of 1s and 0s
|
||||
var/percentage = (PRG.progress / PRG.target_progress) * 100
|
||||
var/list/strings[0]
|
||||
for(var/j, j<10, j++)
|
||||
var/string = ""
|
||||
for(var/i, i<20, i++)
|
||||
string = "[string][prob(percentage)]"
|
||||
strings.Add(string)
|
||||
data["dos_strings"] = strings
|
||||
|
||||
ui = GLOB.nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "access_decrypter.tmpl", "NTNet Access Decrypter", 550, 400, state = state)
|
||||
ui.auto_update_layout = 1
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
@@ -31,6 +31,7 @@
|
||||
data["ntnetlogs"] = ntnet_global.logs
|
||||
data["ntnetmaxlogs"] = ntnet_global.setting_maxlogcount
|
||||
|
||||
data["banned_nids"] = list(ntnet_global.banned_nids)
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
@@ -41,21 +42,19 @@
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/datum/nano_module/computer_ntnetmonitor/Topic(href, href_list)
|
||||
/datum/nano_module/computer_ntnetmonitor/Topic(href, href_list, state)
|
||||
var/mob/user = usr
|
||||
if(..())
|
||||
return 1
|
||||
if(href_list["resetIDS"])
|
||||
. = 1
|
||||
if(ntnet_global)
|
||||
ntnet_global.resetIDS()
|
||||
return 1
|
||||
if(href_list["toggleIDS"])
|
||||
. = 1
|
||||
if(ntnet_global)
|
||||
ntnet_global.toggleIDS()
|
||||
return 1
|
||||
if(href_list["toggleWireless"])
|
||||
. = 1
|
||||
if(!ntnet_global)
|
||||
return 1
|
||||
|
||||
@@ -65,7 +64,6 @@
|
||||
return 1
|
||||
|
||||
// NTNet is enabled and user is about to shut it down. Let's ask them if they really want to do it, as wirelessly connected computers won't connect without NTNet being enabled (which may prevent people from turning it back on)
|
||||
var/mob/user = usr
|
||||
if(!user)
|
||||
return 1
|
||||
var/response = alert(user, "Really disable NTNet wireless? If your computer is connected wirelessly you won't be able to turn it back on! This will affect all connected wireless devices.", "NTNet shutdown", "Yes", "No")
|
||||
@@ -73,17 +71,30 @@
|
||||
ntnet_global.setting_disabled = 1
|
||||
return 1
|
||||
if(href_list["purgelogs"])
|
||||
. = 1
|
||||
if(ntnet_global)
|
||||
ntnet_global.purge_logs()
|
||||
return 1
|
||||
if(href_list["updatemaxlogs"])
|
||||
. = 1
|
||||
var/mob/user = usr
|
||||
var/logcount = text2num(input(user,"Enter amount of logs to keep in memory ([MIN_NTNET_LOGS]-[MAX_NTNET_LOGS]):"))
|
||||
if(ntnet_global)
|
||||
ntnet_global.update_max_log_count(logcount)
|
||||
return 1
|
||||
if(href_list["toggle_function"])
|
||||
. = 1
|
||||
if(!ntnet_global)
|
||||
return 1
|
||||
ntnet_global.toggle_function(href_list["toggle_function"])
|
||||
return 1
|
||||
if(href_list["ban_nid"])
|
||||
if(!ntnet_global)
|
||||
return 1
|
||||
var/nid = input(user,"Enter NID of device which you want to block from the network:", "Enter NID") as null|num
|
||||
if(nid && CanUseTopic(user, state))
|
||||
ntnet_global.banned_nids |= nid
|
||||
return 1
|
||||
if(href_list["unban_nid"])
|
||||
if(!ntnet_global)
|
||||
return 1
|
||||
var/nid = input(user,"Enter NID of device which you want to unblock from the network:", "Enter NID") as null|num
|
||||
if(nid && CanUseTopic(user, state))
|
||||
ntnet_global.banned_nids -= nid
|
||||
return 1
|
||||
|
||||
@@ -58,6 +58,9 @@ var/global/ntnet_card_uid = 1
|
||||
/obj/item/weapon/computer_hardware/network_card/proc/get_network_tag()
|
||||
return "[identification_string] (NID [identification_id])"
|
||||
|
||||
/obj/item/weapon/computer_hardware/network_card/proc/is_banned()
|
||||
return ntnet_global.check_banned(identification_id)
|
||||
|
||||
// 0 - No signal, 1 - Low signal, 2 - High signal. 3 - Wired Connection
|
||||
/obj/item/weapon/computer_hardware/network_card/proc/get_signal(var/specific_action = 0)
|
||||
if(!holder2) // Hardware is not installed in anything. No signal. How did this even get called?
|
||||
@@ -66,13 +69,13 @@ var/global/ntnet_card_uid = 1
|
||||
if(!enabled)
|
||||
return 0
|
||||
|
||||
if(!check_functionality())
|
||||
if(!check_functionality() || !ntnet_global || is_banned())
|
||||
return 0
|
||||
|
||||
if(ethernet) // Computer is connected via wired connection.
|
||||
return 3
|
||||
|
||||
if(!ntnet_global || !ntnet_global.check_function(specific_action)) // NTNet is down and we are not connected via wired connection. No signal.
|
||||
if(!ntnet_global.check_function(specific_action)) // NTNet is down and we are not connected via wired connection. No signal.
|
||||
return 0
|
||||
|
||||
if(holder2)
|
||||
|
||||
Reference in New Issue
Block a user