Update Program.cs

Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
2024-11-06 22:51:54 +07:00
parent 1d35170d6d
commit 453ff6611d

View File

@@ -303,12 +303,18 @@ namespace domain_utility
do do
{ {
key = Console.ReadKey(true); key = Console.ReadKey(true);
if (key.KeyChar < 32 || key.KeyChar > 126)
continue;
if (key.Key == ConsoleKey.Backspace && password.Length > 0) if (key.Key == ConsoleKey.Backspace && password.Length > 0)
{
password = password.Substring(0, password.Length - 1); password = password.Substring(0, password.Length - 1);
Console.Write("\b \b");
}
else if (key.KeyChar < 32 || key.KeyChar > 126)
continue;
else if (key.Key != ConsoleKey.Backspace) else if (key.Key != ConsoleKey.Backspace)
{
password += key.KeyChar; password += key.KeyChar;
Console.Write("*");
}
} }
while (key.Key != ConsoleKey.Enter); while (key.Key != ConsoleKey.Enter);
Console.Write("\n\n"); Console.Write("\n\n");
@@ -321,6 +327,8 @@ namespace domain_utility
int indexOfUserName = machineNameAndUser.IndexOf('\\') + 1; int indexOfUserName = machineNameAndUser.IndexOf('\\') + 1;
string machineUser = machineNameAndUser.Substring(indexOfUserName, machineNameAndUser.Length - indexOfUserName).ToLower(); string machineUser = machineNameAndUser.Substring(indexOfUserName, machineNameAndUser.Length - indexOfUserName).ToLower();
try
{
using (SshClient client = new SshClient(remote, machineUser, password)) using (SshClient client = new SshClient(remote, machineUser, password))
{ {
client.Connect(); client.Connect();
@@ -329,6 +337,11 @@ namespace domain_utility
client.Disconnect(); client.Disconnect();
} }
} }
catch (Exception ex)
{
Console.WriteLine("Произошла ошибка: " + ex.Message);
}
}
private static void FixConky() private static void FixConky()
{ {
@@ -337,6 +350,8 @@ namespace domain_utility
string password = InputPassword(); string password = InputPassword();
Console.WriteLine(password);
ExecuteCommandViaSSH(remote, password, "sudo sed -i 's/update_interval = 0.5,/update_interval = 300,/' /etc/conky/conky.conf"); ExecuteCommandViaSSH(remote, password, "sudo sed -i 's/update_interval = 0.5,/update_interval = 300,/' /etc/conky/conky.conf");
BackToMenu(FixConky); BackToMenu(FixConky);
@@ -391,7 +406,7 @@ namespace domain_utility
"4 - удаленно подключиться к компьютеру (Windows -> Windows, Windows -> Linux)", // StartRDPConnection "4 - удаленно подключиться к компьютеру (Windows -> Windows, Windows -> Linux)", // StartRDPConnection
"5 - удаленная перезагрузка компьютера (только Windows)", // RemoteRebootWindows "5 - удаленная перезагрузка компьютера (только Windows)", // RemoteRebootWindows
"6 - открыть CUPS выбранного компьютера (только Linux)", // OpenComputerCups "6 - открыть CUPS выбранного компьютера (только Linux)", // OpenComputerCups
"7 - изменить время обновления conky с 0.5 на 300", // FixConky "7 - изменить время обновления conky с 0.5 на 300 (только Linux)", // FixConky
"8 - удаленная перезагрузка компьютера (только Linux)", // RemoteRebootLinux "8 - удаленная перезагрузка компьютера (только Linux)", // RemoteRebootLinux
"9 - выполнить команду удаленно (только Windows -> Linux)", // ExecuteCustomCommandViaSSH "9 - выполнить команду удаленно (только Windows -> Linux)", // ExecuteCustomCommandViaSSH
}; };