mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-27 15:07:03 +01:00
Remote interactive mode for CLI
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user