From 228c6bd94a0136e52c216fa9196918e3ab9a8897 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 14 Sep 2017 16:24:56 -0400 Subject: [PATCH] Remote interactive mode for CLI --- TGCommandLine/Program.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/TGCommandLine/Program.cs b/TGCommandLine/Program.cs index 0fcbd4d2f8..dffe214070 100644 --- a/TGCommandLine/Program.cs +++ b/TGCommandLine/Program.cs @@ -57,6 +57,7 @@ namespace TGCommandLine Console.Write("*"); } } + Console.WriteLine(); return result; } @@ -66,6 +67,7 @@ namespace TGCommandLine if (args.Length != 0) return (int)RunCommandLine(new List(args)); + Console.WriteLine("Type 'remote' to connect to a remote service"); //interactive mode while (true) { @@ -73,6 +75,35 @@ namespace TGCommandLine var NextCommand = Console.ReadLine(); switch (NextCommand.ToLower()) { + case "remote": + Console.Write("Enter server address: "); + var address = Console.ReadLine(); + Console.Write("Enter username: "); + var username = Console.ReadLine(); + Console.Write("Enter password: "); + var password = ReadLineSecure(); + Server.SetRemoteLoginInformation(address, username, password); + var res = Server.VerifyConnection(); + if (res != null) + { + Console.WriteLine("Unable to connect: " + res); + Server.SetRemoteLoginInformation(null, null, null); + } + else if (!Server.Authenticate()) + { + Console.WriteLine("Authentication error! Username/password/windows identity is not authorized! Returning to local mode."); + Server.SetRemoteLoginInformation(null, null, null); + } + else + { + Console.WriteLine("Connected remotely"); + Console.WriteLine("Type 'disconnect' to return to local mode"); + } + break; + case "disconnect": + Server.SetRemoteLoginInformation(null, null, null); + Console.WriteLine("Switch to local mode"); + break; case "quit": case "exit": return (int)ExitCode.Normal;