mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-22 12:29:46 +01:00
NTNet Monitoring Tool
- Adds new program, NTNet monitoring tool. It allows the user to view logs and perform various administrative tasks. - The program is currently without access restriction. This will be added in future update, possibly when (if?) i add IT technician. - This program may be used to disable specific functions of NTNet, or shut it down entirely.
This commit is contained in:
@@ -12,10 +12,15 @@ var/global/datum/ntnet/ntnet_global = new()
|
||||
// High values make displaying logs much laggier.
|
||||
var/setting_maxlogcount = 100
|
||||
|
||||
// These only affect wireless. LAN (consoles) are unaffected since it would be possible to create scenario where someone turns off NTNet, and is unable to turn it back on since it refuses connections
|
||||
var/setting_softwaredownload = 1
|
||||
var/setting_peertopeer = 1
|
||||
var/setting_communication = 1
|
||||
var/setting_systemcontrol = 1
|
||||
var/setting_disabled = 0 // Setting to 1 will disable all wireless, independently on relays status.
|
||||
|
||||
var/intrusion_detection_enabled = 1 // Whether the IDS warning system is enabled
|
||||
var/intrusion_detection_alarm = 0 // Set when there is an IDS warning due to malicious (antag) software. Currently only for monitor UI testing, things that would set it are not coded yet
|
||||
|
||||
|
||||
// If new NTNet datum is spawned, it replaces the old one.
|
||||
@@ -59,6 +64,9 @@ var/global/datum/ntnet/ntnet_global = new()
|
||||
operating = 1
|
||||
break
|
||||
|
||||
if(setting_disabled)
|
||||
return 0
|
||||
|
||||
if(specific_action == NTNET_SOFTWAREDOWNLOAD)
|
||||
return (operating && setting_softwaredownload)
|
||||
if(specific_action == NTNET_PEERTOPEER)
|
||||
@@ -93,13 +101,45 @@ var/global/datum/ntnet/ntnet_global = new()
|
||||
if(filename == P.filename)
|
||||
return P
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Resets the IDS alarm
|
||||
/datum/ntnet/proc/resetIDS()
|
||||
intrusion_detection_alarm = 0
|
||||
|
||||
/datum/ntnet/proc/toggleIDS()
|
||||
resetIDS()
|
||||
intrusion_detection_enabled = !intrusion_detection_enabled
|
||||
|
||||
// Removes all logs
|
||||
/datum/ntnet/proc/purge_logs()
|
||||
logs = list()
|
||||
add_log("-!- LOGS DELETED BY SYSTEM OPERATOR -!-")
|
||||
|
||||
// Updates maximal amount of stored logs. Use this instead of setting the number, it performs required checks.
|
||||
/datum/ntnet/proc/update_max_log_count(var/lognumber)
|
||||
if(!lognumber)
|
||||
return 0
|
||||
// Trim the value if necessary
|
||||
lognumber = between(MIN_NTNET_LOGS, lognumber, MAX_NTNET_LOGS)
|
||||
setting_maxlogcount = lognumber
|
||||
add_log("Configuration Updated. Now keeping [setting_maxlogcount] logs in system memory.")
|
||||
|
||||
/datum/ntnet/proc/toggle_function(var/function)
|
||||
if(!function)
|
||||
return
|
||||
function = text2num(function)
|
||||
switch(function)
|
||||
if(NTNET_SOFTWAREDOWNLOAD)
|
||||
setting_softwaredownload = !setting_softwaredownload
|
||||
add_log("Configuration Updated. Wireless network firewall now [setting_softwaredownload ? "allows" : "disallows"] connection to software repositories.")
|
||||
if(NTNET_PEERTOPEER)
|
||||
setting_peertopeer = !setting_peertopeer
|
||||
add_log("Configuration Updated. Wireless network firewall now [setting_peertopeer ? "allows" : "disallows"] peer to peer network traffic.")
|
||||
if(NTNET_COMMUNICATION)
|
||||
setting_communication = !setting_communication
|
||||
add_log("Configuration Updated. Wireless network firewall now [setting_communication ? "allows" : "disallows"] instant messaging and similar communication services.")
|
||||
if(NTNET_SYSTEMCONTROL)
|
||||
setting_systemcontrol = !setting_systemcontrol
|
||||
add_log("Configuration Updated. Wireless network firewall now [setting_systemcontrol ? "allows" : "disallows"] remote control of station's systems.")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -270,6 +270,7 @@
|
||||
var/mob/user = usr
|
||||
if(hard_drive)
|
||||
P = hard_drive.find_file_by_name(prog)
|
||||
P.computer = src
|
||||
|
||||
if(!P || !istype(P)) // Program not found or it's not executable program.
|
||||
user << "<span class='danger'>\The [src]'s screen shows \"I/O ERROR - Unable to run program\" warning.</span>"
|
||||
|
||||
@@ -91,7 +91,6 @@
|
||||
// This is performed on program startup. May be overriden to add extra logic. Remember to include ..() call. Return 1 on success, 0 on failure.
|
||||
// When implementing new program based device, use this to run the program.
|
||||
/datum/computer_file/program/proc/run_program(var/mob/living/user)
|
||||
|
||||
if(can_run(user, 1))
|
||||
if(nanomodule_path)
|
||||
NM = new nanomodule_path(computer) // Computer is passed here as it's (probably!) physical object. Some UI's perform get_turf() and passing program datum wouldn't go well with this.
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/datum/computer_file/program/ntnetmonitor
|
||||
filename = "ntmonitor"
|
||||
filedesc = "NTNet Diagnostics and Monitoring"
|
||||
program_icon_state = "generic"
|
||||
size = 7
|
||||
requires_ntnet = 1
|
||||
available_on_ntnet = 1
|
||||
nanomodule_path = /datum/nano_module/computer_ntnetmonitor/
|
||||
|
||||
/datum/nano_module/computer_ntnetmonitor
|
||||
name = "NTNet Diagnostics and Monitoring"
|
||||
|
||||
/datum/nano_module/computer_ntnetmonitor/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = default_state)
|
||||
if(!ntnet_global)
|
||||
return
|
||||
|
||||
var/list/data = list()
|
||||
if(program)
|
||||
data = program.get_header_data()
|
||||
|
||||
|
||||
data["ntnetstatus"] = ntnet_global.check_function()
|
||||
data["ntnetrelays"] = ntnet_global.relays.len
|
||||
data["idsstatus"] = ntnet_global.intrusion_detection_enabled
|
||||
data["idsalarm"] = ntnet_global.intrusion_detection_alarm
|
||||
|
||||
data["config_softwaredownload"] = ntnet_global.setting_softwaredownload
|
||||
data["config_peertopeer"] = ntnet_global.setting_peertopeer
|
||||
data["config_communication"] = ntnet_global.setting_communication
|
||||
data["config_systemcontrol"] = ntnet_global.setting_systemcontrol
|
||||
|
||||
data["ntnetlogs"] = ntnet_global.logs
|
||||
data["ntnetmaxlogs"] = ntnet_global.setting_maxlogcount
|
||||
|
||||
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "ntnet_monitor.tmpl", "NTNet Diagnostics and Monitoring Tool", 575, 700, state = state)
|
||||
ui.auto_update_layout = 1
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/datum/nano_module/computer_ntnetmonitor/Topic(href, href_list)
|
||||
if(..())
|
||||
return 1
|
||||
if(href_list["resetIDS"])
|
||||
if(ntnet_global)
|
||||
ntnet_global.resetIDS()
|
||||
return 1
|
||||
if(href_list["toggleIDS"])
|
||||
if(ntnet_global)
|
||||
ntnet_global.toggleIDS()
|
||||
return 1
|
||||
if(href_list["toggleWireless"])
|
||||
if(!ntnet_global)
|
||||
return 1
|
||||
|
||||
// NTNet is disabled. Enabling can be done without user prompt
|
||||
if(ntnet_global.setting_disabled)
|
||||
ntnet_global.setting_disabled = 0
|
||||
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
|
||||
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")
|
||||
if(response == "Yes")
|
||||
ntnet_global.setting_disabled = 1
|
||||
return 1
|
||||
if(href_list["purgelogs"])
|
||||
if(ntnet_global)
|
||||
ntnet_global.purge_logs()
|
||||
if(href_list["updatemaxlogs"])
|
||||
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)
|
||||
if(href_list["toggle_function"])
|
||||
if(!ntnet_global)
|
||||
return
|
||||
ntnet_global.toggle_function(href_list["toggle_function"])
|
||||
Reference in New Issue
Block a user