Skip to content

Commit

Permalink
Перерабатываем телнет
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexMorgan3817 committed Mar 9, 2020
1 parent eff666f commit bd44d0d
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 97 deletions.
1 change: 1 addition & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions code/__defines/_inf/_inf.misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions code/__defines/_inf/_inf.modulars.dm
Original file line number Diff line number Diff line change
@@ -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
13 changes: 1 addition & 12 deletions code/modules/modular_computers/hardware/hard_drive.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
117 changes: 41 additions & 76 deletions code/modules/modular_computers/terminal/terminal_commands.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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<br>"
else
. += "\[ENCRYPTED]" + "." + "\[ENCRYPTED]" + " | " + "\[ENCRYPTED]" + " GQ<br>"
return
if(F.is_illegal == 0) . += F.filename + "." + F.filetype + " | " + num2text(F.size) + " GQ<br>"
else . += "\[ENCRYPTED]" + "." + "\[ENCRYPTED]" + " | " + "\[ENCRYPTED]" + " GQ<br>"

/datum/terminal_command/shutdown
name = "shutdown"
Expand Down Expand Up @@ -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: <font color='#00ff00'>Connection established with login: [login], and password: [password].</font>"
else
return "<font color='#ff0000'>telnet: INCORRECT PASSWORD.</font>"
else
return "<font color='#ff0000'>telnet: INCORRECT LOGIN.</font>"
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: <font color='#00ff00'>Connection established with login: [login], and password: [password].</font>"
else return "<font color='#ff0000'>telnet: INCORRECT PASSWORD.</font>"
else return "<font color='#ff0000'>telnet: INCORRECT LOGIN.</font>"
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"
Expand Down Expand Up @@ -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."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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\]\
Expand All @@ -20,12 +20,14 @@ 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."
/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."
*/
Original file line number Diff line number Diff line change
@@ -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, "<br>")
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)]<br>"

3 changes: 0 additions & 3 deletions infinity/code/modules/modular_computers/file_system/data.dm

This file was deleted.

0 comments on commit bd44d0d

Please sign in to comment.