Remote interactive mode for CLI

This commit is contained in:
Cyberboss
2017-09-14 16:24:56 -04:00
parent 6f6eff3612
commit 228c6bd94a
+31
View File
@@ -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<string>(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;