Updates Part Eleven

This commit is contained in:
Unknown
2019-04-13 19:30:30 -04:00
parent ced7e8d3b0
commit 042720823a
14 changed files with 271 additions and 28 deletions

View File

@@ -22,4 +22,6 @@
#define qdel_null(x) if(x) { qdel(x) ; x = null } #define qdel_null(x) if(x) { qdel(x) ; x = null }
#define random_id(key,min_id,max_id) uniqueness_repository.Generate(/datum/uniqueness_generator/id_random, key, min_id, max_id)
#define ARGS_DEBUG log_debug("[__FILE__] - [__LINE__]") ; for(var/arg in args) { log_debug("\t[log_info_line(arg)]") } #define ARGS_DEBUG log_debug("[__FILE__] - [__LINE__]") ; for(var/arg in args) { log_debug("\t[log_info_line(arg)]") }

View File

@@ -0,0 +1,70 @@
var/repository/unique/uniqueness_repository = new()
/repository/unique
var/list/generators
/repository/unique/New()
..()
generators = list()
/repository/unique/proc/Generate()
var/generator_type = args[1]
var/datum/uniqueness_generator/generator = generators[generator_type]
if(!generator)
generator = new generator_type()
generators[generator_type] = generator
var/list/generator_args = args.Copy() // Cannot cut args directly, BYOND complains about it being readonly.
generator_args -= generator_type
return generator.Generate(arglist(generator_args))
/datum/uniqueness_generator/proc/Generate()
return
/datum/uniqueness_generator/id_sequential
var/list/ids_by_key
/datum/uniqueness_generator/id_sequential/New()
..()
ids_by_key = list()
/datum/uniqueness_generator/id_sequential/Generate(var/key, var/default_id = 100)
var/id = ids_by_key[key]
if(id)
id++
else
id = default_id
ids_by_key[key] = id
. = id
/datum/uniqueness_generator/id_random
var/list/ids_by_key
/datum/uniqueness_generator/id_random/New()
..()
ids_by_key = list()
/datum/uniqueness_generator/id_random/Generate(var/key, var/min, var/max)
var/list/ids = ids_by_key[key]
if(!ids)
ids = list()
ids_by_key[key] = ids
if(ids.len >= (max - min) + 1)
error("Random ID limit reached for key [key].")
ids.Cut()
if(ids.len >= 0.6 * ((max-min) + 1)) // if more than 60% of possible ids used
. = list()
for(var/i = min to max)
if(i in ids)
continue
. += i
var/id = pick(.)
ids += id
return id
else
do
. = rand(min, max)
while(. in ids)
ids += .

View File

@@ -497,12 +497,13 @@ var/global/datum/controller/occupations/job_master
// EMAIL GENERATION // EMAIL GENERATION
// Email addresses will be created under this domain name. Mostly for the looks. // Email addresses will be created under this domain name. Mostly for the looks.
var/domain = "freemail.nt" var/domain = "freemail.nt"
var/complete_login = "[replacetext(lowertext(H.real_name), " ", ".")]@[domain]" var/sanitized_name = sanitize(replacetext(replacetext(lowertext(H.real_name), " ", "."), "'", ""))
var/complete_login = "[sanitized_name]@[domain]"
// It is VERY unlikely that we'll have two players, in the same round, with the same name and branch, but still, this is here. // It is VERY unlikely that we'll have two players, in the same round, with the same name and branch, but still, this is here.
// If such conflict is encountered, a random number will be appended to the email address. If this fails too, no email account will be created. // If such conflict is encountered, a random number will be appended to the email address. If this fails too, no email account will be created.
if(ntnet_global.does_email_exist(complete_login)) if(ntnet_global.does_email_exist(complete_login))
complete_login = "[replacetext(lowertext(H.real_name), " ", ".")][rand(100, 999)]@[domain]" complete_login = "[sanitized_name][random_id(/datum/computer_file/data/email_account/, 100, 999)]@[domain]"
// If even fallback login generation failed, just don't give them an email. The chance of this happening is astronomically low. // If even fallback login generation failed, just don't give them an email. The chance of this happening is astronomically low.
if(ntnet_global.does_email_exist(complete_login)) if(ntnet_global.does_email_exist(complete_login))

View File

@@ -11,6 +11,7 @@ var/global/datum/ntnet/ntnet_global = new()
var/list/chat_channels = list() var/list/chat_channels = list()
var/list/fileservers = 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/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. // 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. // High values make displaying logs much laggier.
var/setting_maxlogcount = 100 var/setting_maxlogcount = 100
@@ -60,6 +61,16 @@ var/global/datum/ntnet/ntnet_global = new()
else else
break 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. // Checks whether NTNet operates. If parameter is passed checks whether specific function is enabled.
/datum/ntnet/proc/check_function(var/specific_action = 0) /datum/ntnet/proc/check_function(var/specific_action = 0)
if(!relays || !relays.len) // No relays found. NTNet is down if(!relays || !relays.len) // No relays found. NTNet is down

View File

@@ -81,10 +81,16 @@
dos_failure = 0 dos_failure = 0
update_icon() update_icon()
ntnet_global.add_log("Quantum relay manually restarted from overload recovery mode to normal operation mode.") ntnet_global.add_log("Quantum relay manually restarted from overload recovery mode to normal operation mode.")
return 1
else if(href_list["toggle"]) else if(href_list["toggle"])
enabled = !enabled enabled = !enabled
ntnet_global.add_log("Quantum relay manually [enabled ? "enabled" : "disabled"].") ntnet_global.add_log("Quantum relay manually [enabled ? "enabled" : "disabled"].")
update_icon() 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() /obj/machinery/ntnet_relay/New()
uid = gl_uid uid = gl_uid

View File

@@ -122,15 +122,18 @@
if(tesla_link && tesla_link.enabled && apc_powered) if(tesla_link && tesla_link.enabled && apc_powered)
data["PC_apclinkicon"] = "charging.gif" data["PC_apclinkicon"] = "charging.gif"
switch(get_ntnet_status()) if(network_card && network_card.is_banned())
if(0) data["PC_ntneticon"] = "sig_warning.gif"
data["PC_ntneticon"] = "sig_none.gif" else
if(1) switch(get_ntnet_status())
data["PC_ntneticon"] = "sig_low.gif" if(0)
if(2) data["PC_ntneticon"] = "sig_none.gif"
data["PC_ntneticon"] = "sig_high.gif" if(1)
if(3) data["PC_ntneticon"] = "sig_low.gif"
data["PC_ntneticon"] = "sig_lan.gif" if(2)
data["PC_ntneticon"] = "sig_high.gif"
if(3)
data["PC_ntneticon"] = "sig_lan.gif"
var/list/program_headers = list() var/list/program_headers = list()
for(var/datum/computer_file/program/P in idle_threads) for(var/datum/computer_file/program/P in idle_threads)

View File

@@ -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)

View File

@@ -31,6 +31,7 @@
data["ntnetlogs"] = ntnet_global.logs data["ntnetlogs"] = ntnet_global.logs
data["ntnetmaxlogs"] = ntnet_global.setting_maxlogcount 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) ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui) if (!ui)
@@ -41,21 +42,19 @@
ui.open() ui.open()
ui.set_auto_update(1) 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(..()) if(..())
return 1 return 1
if(href_list["resetIDS"]) if(href_list["resetIDS"])
. = 1
if(ntnet_global) if(ntnet_global)
ntnet_global.resetIDS() ntnet_global.resetIDS()
return 1 return 1
if(href_list["toggleIDS"]) if(href_list["toggleIDS"])
. = 1
if(ntnet_global) if(ntnet_global)
ntnet_global.toggleIDS() ntnet_global.toggleIDS()
return 1 return 1
if(href_list["toggleWireless"]) if(href_list["toggleWireless"])
. = 1
if(!ntnet_global) if(!ntnet_global)
return 1 return 1
@@ -65,7 +64,6 @@
return 1 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) // 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) if(!user)
return 1 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") 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 ntnet_global.setting_disabled = 1
return 1 return 1
if(href_list["purgelogs"]) if(href_list["purgelogs"])
. = 1
if(ntnet_global) if(ntnet_global)
ntnet_global.purge_logs() ntnet_global.purge_logs()
return 1
if(href_list["updatemaxlogs"]) 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]):")) var/logcount = text2num(input(user,"Enter amount of logs to keep in memory ([MIN_NTNET_LOGS]-[MAX_NTNET_LOGS]):"))
if(ntnet_global) if(ntnet_global)
ntnet_global.update_max_log_count(logcount) ntnet_global.update_max_log_count(logcount)
return 1
if(href_list["toggle_function"]) if(href_list["toggle_function"])
. = 1
if(!ntnet_global) if(!ntnet_global)
return 1 return 1
ntnet_global.toggle_function(href_list["toggle_function"]) 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

View File

@@ -58,6 +58,9 @@ var/global/ntnet_card_uid = 1
/obj/item/weapon/computer_hardware/network_card/proc/get_network_tag() /obj/item/weapon/computer_hardware/network_card/proc/get_network_tag()
return "[identification_string] (NID [identification_id])" 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 // 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) /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? 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) if(!enabled)
return 0 return 0
if(!check_functionality()) if(!check_functionality() || !ntnet_global || is_banned())
return 0 return 0
if(ethernet) // Computer is connected via wired connection. if(ethernet) // Computer is connected via wired connection.
return 3 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 return 0
if(holder2) if(holder2)

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

View File

@@ -0,0 +1,12 @@
{{:helper.syndicateMode()}}
{{if data.message}}
##INFO: {{:data.message}}<br><br>{{:helper.link('RESET', null, { 'PRG_reset' : 1 })}}
{{else data.running}}
##Attempting to decrypt network access codes. Please wait. Rate: {{:data.rate}} PHash/s<br>
{{for data.dos_strings}}
{{:value}}<br>
{{/for}}
{{:helper.link('ABORT', null, { 'PRG_reset' : 1 })}}
{{else}}
##System ready<br><br>{{:helper.link('EXECUTE', null, { 'PRG_execute' : 1 })}}
{{/if}}

View File

@@ -52,14 +52,14 @@
<h1>SECURITY SYSTEMS</h1> <h1>SECURITY SYSTEMS</h1>
{{if data.idsalarm}} {{if data.idsalarm}}
<div class="statusDisplay" style="overflow: auto;"> <div class="statusDisplay" style="overflow: auto;">
<div class="item"> <div class="item">
<div class="itemContent" style="width: 100%;"> <div class="itemContent" style="width: 100%;">
<h1>NETWORK INCURSION DETECTED</h1> <h1>NETWORK INCURSION DETECTED</h1>
<i>An abnormal activity has been detected in the network. Please verify system logs for more information</i> <i>An abnormal activity has been detected in the network. Please verify system logs for more information</i>
</div> </div>
</div> </div>
</div> </div>
{{/if}} {{/if}}
<div class="item"> <div class="item">
<div class="itemLabelWide"> <div class="itemLabelWide">
@@ -76,7 +76,15 @@
<div class="itemContentNarrow"> <div class="itemContentNarrow">
<b>{{:data.ntnetmaxlogs}}</b> <b>{{:data.ntnetmaxlogs}}</b>
</div> </div>
</div> </div>
<div class="item">
<div class="itemLabelWide">
Blacklisted NIDs:
</div>
<div class="itemContentNarrow">
{{:data.banned_nids}}
</div>
</div>
<div class="item"> <div class="item">
<div class="itemLabelWide"> <div class="itemLabelWide">
Controls: Controls:
@@ -87,11 +95,13 @@
<tr><td>{{:helper.link('TOGGLE IDS', null, {'toggleIDS' : 1})}} <tr><td>{{:helper.link('TOGGLE IDS', null, {'toggleIDS' : 1})}}
<tr><td>{{:helper.link('SET LOG LIMIT', null, {'updatemaxlogs' : 1})}} <tr><td>{{:helper.link('SET LOG LIMIT', null, {'updatemaxlogs' : 1})}}
<tr><td>{{:helper.link('PURGE LOGS', null, {'purgelogs' : 1})}} <tr><td>{{:helper.link('PURGE LOGS', null, {'purgelogs' : 1})}}
<tr><td>{{:helper.link('ADD BLACKLIST ENTRY', null, {'ban_nid' : 1})}}
<tr><td>{{:helper.link('REMOVE BLACKLIST ENTRY', null, {'unban_nid' : 1})}}
</table> </table>
</div> </div>
</div> </div>
<b>System Logs</b> <b>System Logs</b>
<div class="statusDisplay" style="overflow: auto;"> <div class="statusDisplay" style="overflow: auto;">
<div class="item"> <div class="item">
<div class="itemContent" style="width: 100%;"> <div class="itemContent" style="width: 100%;">
{{for data.ntnetlogs}} {{for data.ntnetlogs}}
@@ -99,4 +109,4 @@
{{/for}} {{/for}}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -23,4 +23,10 @@
<div class="itemContent"> <div class="itemContent">
{{:data.dos_overload}} / {{:data.dos_capacity}} GQ {{:data.dos_overload}} / {{:data.dos_capacity}} GQ
</div> </div>
<div class="itemLabel">
Options:
</div>
<div class="itemContent">
{{:helper.link('Purge network blacklist', null, { 'purge' : 1 })}}
</div>
{{/if}} {{/if}}

View File

@@ -310,6 +310,7 @@
#include "code\datums\repositories\decls.dm" #include "code\datums\repositories\decls.dm"
#include "code\datums\repositories\radiation.dm" #include "code\datums\repositories\radiation.dm"
#include "code\datums\repositories\repository.dm" #include "code\datums\repositories\repository.dm"
#include "code\datums\repositories\unique.dm"
#include "code\datums\supplypacks\atmospherics.dm" #include "code\datums\supplypacks\atmospherics.dm"
#include "code\datums\supplypacks\contraband.dm" #include "code\datums\supplypacks\contraband.dm"
#include "code\datums\supplypacks\costumes.dm" #include "code\datums\supplypacks\costumes.dm"