From bd44d0d0db6b70de8a1fb5b0eee365fe75a50463 Mon Sep 17 00:00:00 2001 From: AlexMorgan3817 Date: Mon, 9 Mar 2020 18:41:33 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=B0=D1=82=D1=8B=D0=B2=D0=B0=D0=B5=D0=BC=20=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D0=BD=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- baystation12.dme | 1 + code/__defines/_inf/_inf.misc.dm | 3 - code/__defines/_inf/_inf.modulars.dm | 4 + .../modular_computers/hardware/hard_drive.dm | 13 +- .../terminal/terminal_commands.dm | 117 ++++++------------ .../file_system/coding_data.dm | 8 +- .../file_system/configuration_data.dm | 20 +++ .../modular_computers/file_system/data.dm | 3 - 8 files changed, 72 insertions(+), 97 deletions(-) create mode 100644 code/__defines/_inf/_inf.modulars.dm create mode 100644 infinity/code/modules/modular_computers/file_system/configuration_data.dm delete mode 100644 infinity/code/modules/modular_computers/file_system/data.dm diff --git a/baystation12.dme b/baystation12.dme index 6f5fa97cd9..34496957a4 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -3474,6 +3474,7 @@ #include "infinity\code\modules\modular_computers\computers\modular_computer\interaction.dm" #include "infinity\code\modules\modular_computers\computers\subtypes\dev_wrist.dm" #include "infinity\code\modules\modular_computers\file_system\coding_data.dm" +#include "infinity\code\modules\modular_computers\file_system\configuration_data.dm" #include "infinity\code\modules\modular_computers\file_system\programs\civilian\crusher_control.dm" #include "infinity\code\modules\modular_computers\file_system\programs\generic\codeprocessor.dm" #include "infinity\code\modules\modular_computers\hardware\network_card.dm" diff --git a/code/__defines/_inf/_inf.misc.dm b/code/__defines/_inf/_inf.misc.dm index 138e427f3e..d47fad4904 100644 --- a/code/__defines/_inf/_inf.misc.dm +++ b/code/__defines/_inf/_inf.misc.dm @@ -26,6 +26,3 @@ #define USE_FAIL_INCAPACITATED 5 #define USE_FAIL_NOT_IN_USER 6 #define USE_FAIL_IS_SILICON 7 - -#define NTNET_RADIUS_MULTIPLIER config.ntnet_radius_multiplyer -#define NTNET_SPEED_LIMITER config.ntnet_speed_limiter diff --git a/code/__defines/_inf/_inf.modulars.dm b/code/__defines/_inf/_inf.modulars.dm new file mode 100644 index 0000000000..6b5d328584 --- /dev/null +++ b/code/__defines/_inf/_inf.modulars.dm @@ -0,0 +1,4 @@ +#define TELNETPASS_SETTING "telnet_pass" + +#define NTNET_RADIUS_MULTIPLIER config.ntnet_radius_multiplyer +#define NTNET_SPEED_LIMITER config.ntnet_speed_limiter diff --git a/code/modules/modular_computers/hardware/hard_drive.dm b/code/modules/modular_computers/hardware/hard_drive.dm index c192e20971..0e61831a22 100644 --- a/code/modules/modular_computers/hardware/hard_drive.dm +++ b/code/modules/modular_computers/hardware/hard_drive.dm @@ -76,18 +76,7 @@ store_file(new/datum/computer_file/program/ntnetdownload(src)) // NTNet Downloader Utility, allows users to download more software from NTNet repository store_file(new/datum/computer_file/program/filemanager(src)) // File manager, allows text editor functions and basic file manipulation. - var/datum/computer_file/data/config/file = new() - file.filename = "TNet_CONFIG" - file.stored_data += "ROOT : [round(rand(1000, 9999))]" //LOGIN : PASSWORD - store_file(file) - - var/datum/computer_file/data/text/file_README = new() - file_README.filename = "TNet_CONFIG_README" - file_README.stored_data += "\[large\]\[b\]DO NOT DELETE OR RENAME FILE TNet_CONFIG IF YOU DO NOT WANT TO PUT YOUR DEVICE AT RISK \[/b\]\[/large\]\[br\]" - file_README.stored_data += "Format login and password in TNet_CONFIG: \[LOGIN\] : \[PASSWORD\].\[br\]" - file_README.stored_data += "Login must contain only 4 characters, password may be anything.\[br\]" - file_README.stored_data += "If pword and login don't work, then delete file \"TNet_CONFIG\" and enter in terminal command \"telnet\" without arguments." - store_file(file_README) + store_file(new/datum/computer_file/data/config/main(src))//inf // Use this proc to remove file from the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks. /obj/item/weapon/stock_parts/computer/hard_drive/proc/remove_file(var/datum/computer_file/F) diff --git a/code/modules/modular_computers/terminal/terminal_commands.dm b/code/modules/modular_computers/terminal/terminal_commands.dm index 4677a3724d..1b759408ac 100644 --- a/code/modules/modular_computers/terminal/terminal_commands.dm +++ b/code/modules/modular_computers/terminal/terminal_commands.dm @@ -292,25 +292,18 @@ inf*/ //[INFINITY]____________________________________________________________________________________________________________________ -/datum/terminal_command/listdir - name = "listdir" - man_entry = list("Format: listdir", "State list of files in local memory.") - pattern = "^listdir$" +/datum/terminal_command/ls + name = "ls" + man_entry = list("Format: ls", "State list of files in local memory.") + pattern = "^ls$" skill_needed = SKILL_ADEPT -/datum/terminal_command/listdir/proper_input_entered(text, mob/user, datum/terminal/terminal) +/datum/terminal_command/ls/proper_input_entered(text, mob/user, datum/terminal/terminal) var/datum/extension/interactive/ntos/CT = terminal.computer - if(length(text) < 6) - return "listdir: Improper syntax. Use listdir." - if(!CT.get_component(PART_HDD).check_functionality()) - return "listdir: Access attempt to local storage failed. Check integrity of your hard drive" + if(!CT.get_component(PART_HDD).check_functionality()) return "[name]: Access attempt to local storage failed. Check integrity of your hard drive" for(var/datum/computer_file/F in CT.get_component(PART_HDD).stored_files) - if(F.is_illegal == 0) - var/prog_size = num2text(F.size) - . += F.filename + "." + F.filetype + " | " + prog_size + " GQ
" - else - . += "\[ENCRYPTED]" + "." + "\[ENCRYPTED]" + " | " + "\[ENCRYPTED]" + " GQ
" - return + if(F.is_illegal == 0) . += F.filename + "." + F.filetype + " | " + num2text(F.size) + " GQ
" + else . += "\[ENCRYPTED]" + "." + "\[ENCRYPTED]" + " | " + "\[ENCRYPTED]" + " GQ
" /datum/terminal_command/shutdown name = "shutdown" @@ -392,73 +385,45 @@ inf*/ /datum/terminal_command/telnet name = "telnet" man_entry = list("Format: telnet \[NID] \[LOGIN] \[PASSWORD].", - "Access remote terminal with login and password", - "If NID < 100 write NID like 001.", - "Use `telnet` to README and config security of your devise.") + "Access remote terminal by login and password") pattern = "^telnet" /datum/terminal_command/telnet/proper_input_entered(text, mob/user, datum/terminal/terminal) var/datum/extension/interactive/ntos/CT = terminal.computer + var/list/T = splittext(text, " ").Copy(2) - if(!copytext(text,7)) - if(CT.get_component(PART_HDD)) - if(!CT.get_component(PART_HDD).find_file_by_name("TNet_CONFIG") && !CT.get_component(PART_HDD).find_file_by_name("TNet_CONFIG_README")) - var/datum/computer_file/data/config/file = CT.get_component(PART_HDD).find_file_by_name("TNet_CONFIG") - if(!istype(file)) - file = new() - file.filename = "TNet_CONFIG" - CT.get_component(PART_HDD).store_file(file) // May fail, which is fine with us. - file.stored_data += "ROOT : [round(rand(1000, 9999))]" //LOGIN : PASSWORD - var/datum/computer_file/data/text/file_README = CT.get_component(PART_HDD).find_file_by_name("TNet_CONFIG_README") - if(!istype(file_README)) - file_README = new() - file_README.filename = "TNet_CONFIG_README" - CT.get_component(PART_HDD).store_file(file_README) // May fail, which is fine with us. - file_README.stored_data += "\[large]\[b]DO NOT DELETE FILE TNet_CONFIG IF YOU DO NOT WANT TO PUT YOUR DEVICE AT RISK \[/b]\[/large]\[br]" //LOGIN : PASSWORD - file_README.stored_data += "Format login and password in TNet_CONFIG: \[LOGIN] : \[PASSWORD].\[br]" - file_README.stored_data += "Login must contain only 4 characters, password may be anything." - return "Config file created. Check config README to study how to change the login and password." - else - return "Config and config README already created." + if(!T?.len) return "telnet: error, not enough arguments." + if(istype(terminal, /datum/terminal/remote)) return "telnet is not supported on remote terminals." - if(istype(terminal, /datum/terminal/remote)) - return "telnet is not supported on remote terminals." - if(!CT || !CT.get_ntnet_status()) - return "telnet: Check network connectivity." - - var/nid = text2num(copytext(text, 8, 11)) - if(copytext(nid, 1,3) == "00") - nid = copytext(nid, 3,4) - else if(copytext(nid, 1,2) == "0") - nid = copytext(nid, 2,3) + var/nid = T[1] + nid = text2num(nid) var/datum/extension/interactive/ntos/comp = ntnet_global.get_os_by_nid(nid) - if(comp == CT) - return "telnet: Error; can not open remote terminal to self." - if(!comp || !comp.host_status() || !comp.get_ntnet_status()) - return "telnet: No active device with this nid found." - if(comp.has_terminal(user)) - return "telnet: A remote terminal to this device is already active." - - var/datum/computer_file/data/config/cfg_file = comp.get_component(PART_HDD).find_file_by_name("TNet_CONFIG") - if(comp.get_component(PART_HDD).find_file_by_name("TNet_CONFIG")) - var/login = copytext(cfg_file.stored_data, 1, 5) - var/password = copytext(cfg_file.stored_data, 8) - if(copytext(text, 12,16) == login) - if(copytext(text, 17) == password) - var/datum/terminal/remote/new_term = new (user, comp, CT) - LAZYADD(comp.terminals, new_term) - LAZYADD(CT.terminals, new_term) - ntnet_global.add_log("[CT.get_component(PART_NETWORK).get_network_tag()] open telnet tunnel to [comp.get_component(PART_NETWORK).get_network_tag()]") - return "telnet: Connection established with login: [login], and password: [password]." - else - return "telnet: INCORRECT PASSWORD." - else - return "telnet: INCORRECT LOGIN." - var/datum/terminal/remote/new_term = new (user, comp, CT) - LAZYADD(comp.terminals, new_term) - LAZYADD(CT.terminals, new_term) - ntnet_global.add_log("[CT.get_component(PART_NETWORK).get_network_tag()] open telnet tunnel to [comp.get_component(PART_NETWORK).get_network_tag()]") - return "telnet: Connection established." + + if(!CT?.get_ntnet_status() && comp?.get_ntnet_status()) return "telnet: 0x12932910 (Network Error) Unable to establishe connection." + if(CT == comp) return "telnet: unable to open remote terminal to self." + + var/datum/computer_file/data/config/cfg_file = comp.get_component(PART_HDD).find_file_by_name("config") + if(cfg_file) + var/list/loginpassword = splittext(cfg_file.get_setting(TELNETPASS_SETTING),"@") + if(loginpassword && loginpassword.len >= 2) + var/login = loginpassword[1] + var/password = loginpassword[2] + if(T[2] == login) + if(T[3] == password) + var/datum/terminal/remote/new_term = new (user, comp, CT) + LAZYADD(comp.terminals, new_term) + LAZYADD(CT.terminals, new_term) + ntnet_global.add_log("[CT.get_component(PART_NETWORK).get_network_tag()] open telnet tunnel to [comp.get_component(PART_NETWORK).get_network_tag()]") + return "telnet: Connection established with login: [login], and password: [password]." + else return "telnet: INCORRECT PASSWORD." + else return "telnet: INCORRECT LOGIN." + else return "telnet: login and password needed." + else + var/datum/terminal/remote/new_term = new(user, comp, CT) + LAZYADD(comp.terminals, new_term) + LAZYADD(CT.terminals, new_term) + ntnet_global.add_log("[CT.get_component(PART_NETWORK).get_network_tag()] open telnet tunnel to [comp.get_component(PART_NETWORK).get_network_tag()]") + return "telnet: Connection established." /datum/terminal_command/remove name = "remove" @@ -566,7 +531,7 @@ inf*/ if(option == "-mn") if(copytext(text, 11, 15) == "-bat") - var/datum/computer_file/data/text/README/coding/batch/BRM = new() + var/datum/computer_file/data/text/batch_manual/BRM = new() CT.get_component(PART_HDD).store_file(BRM) return "alias: batch manual created." diff --git a/infinity/code/modules/modular_computers/file_system/coding_data.dm b/infinity/code/modules/modular_computers/file_system/coding_data.dm index 549e8f414e..ef048c3574 100644 --- a/infinity/code/modules/modular_computers/file_system/coding_data.dm +++ b/infinity/code/modules/modular_computers/file_system/coding_data.dm @@ -10,7 +10,7 @@ GLOBAL_VAR_INIT(coding_languages, list("Batch")) //,"Anaconda", "NTML") code_lang = "Batch" code_lang_desc = "Simple terminal commands code" -/datum/computer_file/data/text/README/coding/batch +/datum/computer_file/data/text/batch_manual filename = "batch_manual" stored_data = "\[center\]\[daislogo\]\[br\]\ \[h1\]=== Batch language manual ===\[/h1\]\[hr\]\ @@ -20,7 +20,8 @@ GLOBAL_VAR_INIT(coding_languages, list("Batch")) //,"Anaconda", "NTML") If command last in program, don't write \';\' after this command.\[hr\]\[/center\]\ To compile your code, you should input in terminal \'alias -ex \[code file name without square brackets\]" -/*/datum/computer_file/data/coding/python_borned/anaconda +/* +/datum/computer_file/data/coding/anaconda filetype = "ANC" code_lang = "Anaconda" code_lang_desc = "Wide oriented utility language, can used for network works, data manipulation and etc." @@ -28,4 +29,5 @@ GLOBAL_VAR_INIT(coding_languages, list("Batch")) //,"Anaconda", "NTML") /datum/computer_file/data/coding/html filetype = "NTM" code_lang = "NTML" - code_lang_desc = "NanoTrasen MarkUp Language, using to create ui for your programs, and maybe news articles."*/ + code_lang_desc = "NanoTrasen MarkUp Language, using to create ui for your programs, and maybe news articles." +*/ diff --git a/infinity/code/modules/modular_computers/file_system/configuration_data.dm b/infinity/code/modules/modular_computers/file_system/configuration_data.dm new file mode 100644 index 0000000000..d62df47a5d --- /dev/null +++ b/infinity/code/modules/modular_computers/file_system/configuration_data.dm @@ -0,0 +1,20 @@ +/datum/computer_file/data/config + filetype = "CFG" + do_not_edit = 1 + +/datum/computer_file/data/config/proc/get_setting(var/setting_name) + . = lowertext(replacetext(stored_data, " ", "")) + . = splittext(stored_data, "
") + for(var/i in .) if(copytext(i, 1, length(setting_name) + 1) == setting_name) + i = splittext(i, ":") + if(i) . = i[2] + break + if(!.) . = null + +/datum/computer_file/data/config/main + filename = "config" + +/datum/computer_file/data/config/main/New() + . = ..() + stored_data += "[TELNETPASS_SETTING]:ROOT@[rand(1000, 9999)]
" + diff --git a/infinity/code/modules/modular_computers/file_system/data.dm b/infinity/code/modules/modular_computers/file_system/data.dm deleted file mode 100644 index e31fdbaed1..0000000000 --- a/infinity/code/modules/modular_computers/file_system/data.dm +++ /dev/null @@ -1,3 +0,0 @@ -/datum/computer_file/data/config - filetype = "CFG" - do_not_edit = 1 \ No newline at end of file