Merge upstream

This commit is contained in:
Cyberboss
2017-10-31 12:44:53 -04:00
25 changed files with 325 additions and 245 deletions
+4 -4
View File
@@ -18,7 +18,7 @@ namespace TGCommandLine
}
}
class AdminRecreateStaticCommand : Command
class AdminRecreateStaticCommand : ConsoleCommand
{
public AdminRecreateStaticCommand()
{
@@ -38,7 +38,7 @@ namespace TGCommandLine
}
}
class AdminViewGroupCommand : Command
class AdminViewGroupCommand : ConsoleCommand
{
public AdminViewGroupCommand()
{
@@ -57,7 +57,7 @@ namespace TGCommandLine
}
}
class AdminSetGroupCommand : Command
class AdminSetGroupCommand : ConsoleCommand
{
public AdminSetGroupCommand()
{
@@ -90,7 +90,7 @@ namespace TGCommandLine
}
}
class AdminClearGroupCommand : Command
class AdminClearGroupCommand : ConsoleCommand
{
public AdminClearGroupCommand()
{
+3 -3
View File
@@ -19,7 +19,7 @@ namespace TGCommandLine
}
}
class BYONDVersionCommand : Command
class BYONDVersionCommand : ConsoleCommand
{
public BYONDVersionCommand()
{
@@ -48,7 +48,7 @@ namespace TGCommandLine
}
class BYONDStatusCommand : Command
class BYONDStatusCommand : ConsoleCommand
{
public BYONDStatusCommand()
{
@@ -88,7 +88,7 @@ namespace TGCommandLine
}
}
class BYONDUpdateCommand : Command
class BYONDUpdateCommand : ConsoleCommand
{
public BYONDUpdateCommand()
{
+17 -17
View File
@@ -29,7 +29,7 @@ namespace TGCommandLine
return "Manages the Discord bot";
}
}
class IRCNickCommand : Command
class IRCNickCommand : ConsoleCommand
{
public IRCNickCommand()
{
@@ -57,7 +57,7 @@ namespace TGCommandLine
}
}
class ChatJoinCommand : Command
class ChatJoinCommand : ConsoleCommand
{
readonly int providerIndex;
public ChatJoinCommand(ChatProvider pI)
@@ -136,7 +136,7 @@ namespace TGCommandLine
}
}
class ChatPartCommand : Command
class ChatPartCommand : ConsoleCommand
{
readonly int providerIndex;
public ChatPartCommand(ChatProvider pI)
@@ -206,7 +206,7 @@ namespace TGCommandLine
return ExitCode.Normal;
}
}
class ChatListAdminsCommand : Command
class ChatListAdminsCommand : ConsoleCommand
{
readonly int providerIndex;
public ChatListAdminsCommand(ChatProvider pI)
@@ -265,7 +265,7 @@ namespace TGCommandLine
return ExitCode.Normal;
}
}
class ChatReconnectCommand : Command
class ChatReconnectCommand : ConsoleCommand
{
readonly ChatProvider providerIndex;
public ChatReconnectCommand(ChatProvider pI)
@@ -290,7 +290,7 @@ namespace TGCommandLine
return ExitCode.Normal;
}
}
class ChatAddminCommand : Command
class ChatAddminCommand : ConsoleCommand
{
readonly int providerIndex;
public ChatAddminCommand(ChatProvider pI)
@@ -337,7 +337,7 @@ namespace TGCommandLine
return ExitCode.Normal;
}
}
class IRCAuthModeCommand : Command
class IRCAuthModeCommand : ConsoleCommand
{
public IRCAuthModeCommand()
{
@@ -376,7 +376,7 @@ namespace TGCommandLine
return ExitCode.Normal;
}
}
class DiscordAuthModeCommand : Command
class DiscordAuthModeCommand : ConsoleCommand
{
public DiscordAuthModeCommand()
{
@@ -415,7 +415,7 @@ namespace TGCommandLine
return ExitCode.Normal;
}
}
class IRCAuthLevelCommand : Command
class IRCAuthLevelCommand : ConsoleCommand
{
public IRCAuthLevelCommand()
{
@@ -463,7 +463,7 @@ namespace TGCommandLine
return ExitCode.Normal;
}
}
class ChatDeadminCommand : Command
class ChatDeadminCommand : ConsoleCommand
{
readonly int providerIndex;
public ChatDeadminCommand(ChatProvider pI)
@@ -511,7 +511,7 @@ namespace TGCommandLine
}
}
class IRCAuthCommand : Command
class IRCAuthCommand : ConsoleCommand
{
public IRCAuthCommand()
{
@@ -539,7 +539,7 @@ namespace TGCommandLine
}
}
class IRCDisableAuthCommand : Command
class IRCDisableAuthCommand : ConsoleCommand
{
public IRCDisableAuthCommand()
{
@@ -561,7 +561,7 @@ namespace TGCommandLine
}
}
class ChatStatusCommand : Command
class ChatStatusCommand : ConsoleCommand
{
readonly int providerIndex;
public ChatStatusCommand(ChatProvider pI)
@@ -594,7 +594,7 @@ namespace TGCommandLine
return ExitCode.Normal;
}
}
class ChatEnableCommand : Command
class ChatEnableCommand : ConsoleCommand
{
readonly int providerIndex;
public ChatEnableCommand(ChatProvider pI)
@@ -622,7 +622,7 @@ namespace TGCommandLine
return ExitCode.Normal;
}
}
class ChatDisableCommand : Command
class ChatDisableCommand : ConsoleCommand
{
readonly int providerIndex;
public ChatDisableCommand(ChatProvider pI)
@@ -651,7 +651,7 @@ namespace TGCommandLine
}
}
class IRCServerCommand : Command
class IRCServerCommand : ConsoleCommand
{
public IRCServerCommand()
{
@@ -696,7 +696,7 @@ namespace TGCommandLine
}
}
class DiscordSetTokenCommand : Command
class DiscordSetTokenCommand : ConsoleCommand
{
public DiscordSetTokenCommand()
{
+5 -5
View File
@@ -18,7 +18,7 @@ namespace TGCommandLine
return "Manage settings";
}
}
class ConfigDeleteCommand : Command
class ConfigDeleteCommand : ConsoleCommand
{
public ConfigDeleteCommand()
{
@@ -46,7 +46,7 @@ namespace TGCommandLine
}
}
class ConfigListCommand : Command
class ConfigListCommand : ConsoleCommand
{
public ConfigListCommand()
{
@@ -79,7 +79,7 @@ namespace TGCommandLine
}
}
class ConfigServerDirectoryCommand : Command
class ConfigServerDirectoryCommand : ConsoleCommand
{
public ConfigServerDirectoryCommand()
{
@@ -98,7 +98,7 @@ namespace TGCommandLine
}
}
class ConfigDownloadCommand : Command
class ConfigDownloadCommand : ConsoleCommand
{
public ConfigDownloadCommand()
{
@@ -136,7 +136,7 @@ namespace TGCommandLine
}
}
class ConfigUploadCommand : Command
class ConfigUploadCommand : ConsoleCommand
{
public ConfigUploadCommand()
{
+12
View File
@@ -0,0 +1,12 @@
using TGServiceInterface;
namespace TGCommandLine
{
abstract class ConsoleCommand : Command
{
/// <summary>
/// The <see cref="TGServiceInterface.Interface"/> currently in use by the <see cref="Program"/>
/// </summary>
public static Interface Interface;
}
}
+9 -9
View File
@@ -18,7 +18,7 @@ namespace TGCommandLine
}
}
class DDWorldAnnounceCommand : Command
class DDWorldAnnounceCommand : ConsoleCommand
{
public DDWorldAnnounceCommand()
{
@@ -44,7 +44,7 @@ namespace TGCommandLine
}
}
class DDStartCommand : Command
class DDStartCommand : ConsoleCommand
{
public DDStartCommand()
{
@@ -64,7 +64,7 @@ namespace TGCommandLine
}
}
class DDStopCommand : Command
class DDStopCommand : ConsoleCommand
{
public DDStopCommand()
{
@@ -98,7 +98,7 @@ namespace TGCommandLine
return res == null ? ExitCode.Normal : ExitCode.ServerError;
}
}
class DDRestartCommand : Command
class DDRestartCommand : ConsoleCommand
{
public DDRestartCommand()
{
@@ -132,7 +132,7 @@ namespace TGCommandLine
return "Restarts the server and watchdog optionally waiting for the current round to end";
}
}
class DDStatusCommand : Command
class DDStatusCommand : ConsoleCommand
{
public DDStatusCommand()
{
@@ -157,7 +157,7 @@ namespace TGCommandLine
}
}
class DDAutostartCommand : Command
class DDAutostartCommand : ConsoleCommand
{
public DDAutostartCommand()
{
@@ -195,7 +195,7 @@ namespace TGCommandLine
return "Change or check autostarting of the game server with the service";
}
}
class DDWebclientCommand : Command
class DDWebclientCommand : ConsoleCommand
{
public DDWebclientCommand()
{
@@ -234,7 +234,7 @@ namespace TGCommandLine
}
}
class DDPortCommand : Command
class DDPortCommand : ConsoleCommand
{
public DDPortCommand()
{
@@ -270,7 +270,7 @@ namespace TGCommandLine
}
}
class DDSecurityCommand : Command
class DDSecurityCommand : ConsoleCommand
{
public DDSecurityCommand()
{
+5 -5
View File
@@ -19,7 +19,7 @@ namespace TGCommandLine
}
}
class DMCompileCommand : Command
class DMCompileCommand : ConsoleCommand
{
public DMCompileCommand()
{
@@ -75,7 +75,7 @@ namespace TGCommandLine
return "Starts a compile/update job optionally waiting for completion";
}
}
class DMStatusCommand : Command
class DMStatusCommand : ConsoleCommand
{
public DMStatusCommand()
{
@@ -123,7 +123,7 @@ namespace TGCommandLine
}
}
class DMSetProjectNameCommand : Command
class DMSetProjectNameCommand : ConsoleCommand
{
public DMSetProjectNameCommand()
{
@@ -147,7 +147,7 @@ namespace TGCommandLine
}
}
class DMInitializeCommand : Command
class DMInitializeCommand : ConsoleCommand
{
public DMInitializeCommand()
{
@@ -197,7 +197,7 @@ namespace TGCommandLine
}
}
class DMCancelCommand : Command
class DMCancelCommand : ConsoleCommand
{
public DMCancelCommand()
{
+34 -24
View File
@@ -9,6 +9,8 @@ namespace TGCommandLine
class Program
{
static bool interactive = false;
static Interface currentInterface;
static Command.ExitCode RunCommandLine(IList<string> argsAsList)
{
//first lookup the connection string
@@ -51,7 +53,7 @@ namespace TGCommandLine
}
argsAsList.RemoveAt(I);
argsAsList.RemoveAt(I);
Interface.SetRemoteLoginInformation(address, port, username, password);
ReplaceInterface(new Interface(address, port, username, password));
break;
}
}
@@ -62,7 +64,7 @@ namespace TGCommandLine
return Command.ExitCode.BadCommand;
}
var res = Interface.VerifyConnection();
var res = currentInterface.VerifyConnection();
if (res != null)
{
Console.WriteLine("Unable to connect to service: " + res);
@@ -70,13 +72,13 @@ namespace TGCommandLine
return Command.ExitCode.ConnectionError;
}
if (!Interface.Authenticate())
if (!currentInterface.Authenticate())
{
Console.WriteLine("Authentication error: Username/password/windows identity is not authorized!");
return Command.ExitCode.ConnectionError;
}
if (!SentVMMWarning && Interface.VersionMismatch(out string error))
if (!SentVMMWarning && currentInterface.VersionMismatch(out string error))
{
SentVMMWarning = true;
Console.WriteLine(error);
@@ -84,7 +86,7 @@ namespace TGCommandLine
try
{
return new CLICommand().DoRun(argsAsList);
return new CLICommand(currentInterface).DoRun(argsAsList);
}
catch (Exception e)
{
@@ -92,6 +94,24 @@ namespace TGCommandLine
return Command.ExitCode.ConnectionError;
};
}
static void ReplaceInterface(Interface I)
{
if (!interactive)
I.SetBadCertificateHandler((message) =>
{
foreach (var J in Environment.GetCommandLineArgs())
if (J.ToLower() == "--disable-ssl-verification") //im just not even going to document this because i hate it so much
return true;
return false;
});
else
I.SetBadCertificateHandler(BadCertificateInteractive);
currentInterface = I;
ConsoleCommand.Interface = I;
}
public static string ReadLineSecure()
{
string result = "";
@@ -138,20 +158,10 @@ namespace TGCommandLine
static int Main(string[] args)
{
ReplaceInterface(new Interface());
Command.OutputProcVar.Value = Console.WriteLine;
if (args.Length != 0)
{
Interface.SetBadCertificateHandler((message) => {
foreach (var I in args)
if (I.ToLower() == "--disable-ssl-verification") //im just not even going to document this because i hate it so much
return true;
return false;
});
//allow self signed certs in debug mode
return (int)RunCommandLine(new List<string>(args));
}
Interface.SetBadCertificateHandler(BadCertificateInteractive);
Console.WriteLine("Type 'remote' to connect to a remote service");
//interactive mode
@@ -179,22 +189,22 @@ namespace TGCommandLine
var username = Console.ReadLine();
Console.Write("Enter password: ");
var password = ReadLineSecure();
Interface.SetRemoteLoginInformation(address, port, username, password);
var res = Interface.VerifyConnection();
ReplaceInterface(new Interface(address, port, username, password));
var res = currentInterface.VerifyConnection();
if (res != null)
{
Console.WriteLine("Unable to connect: " + res);
Interface.MakeLocalConnection();
ReplaceInterface(new Interface());
}
else if (!Interface.Authenticate())
else if (!currentInterface.Authenticate())
{
Console.WriteLine("Authentication error: Username/password/windows identity is not authorized! Returning to local mode...");
Interface.MakeLocalConnection();
ReplaceInterface(new Interface());
}
else
{
Console.WriteLine("Connected remotely");
if (Interface.VersionMismatch(out res))
if (currentInterface.VersionMismatch(out res))
{
SentVMMWarning = true;
Console.WriteLine(res);
@@ -204,7 +214,7 @@ namespace TGCommandLine
break;
case "disconnect":
SentVMMWarning = false;
Interface.MakeLocalConnection();
ReplaceInterface(new Interface());
Console.WriteLine("Switch to local mode");
break;
case "quit":
@@ -212,7 +222,7 @@ namespace TGCommandLine
return (int)Command.ExitCode.Normal;
#if DEBUG
case "debug-upgrade":
Interface.GetComponent<ITGSService>().PrepareForUpdate();
currentInterface.GetComponent<ITGSService>().PrepareForUpdate();
return (int)Command.ExitCode.Normal;
#endif
default:
+13 -13
View File
@@ -18,7 +18,7 @@ namespace TGCommandLine
}
}
class RepoUpdateJsonCommand : Command
class RepoUpdateJsonCommand : ConsoleCommand
{
public RepoUpdateJsonCommand()
{
@@ -42,7 +42,7 @@ namespace TGCommandLine
}
}
class RepoSetupCommand : Command
class RepoSetupCommand : ConsoleCommand
{
public RepoSetupCommand()
{
@@ -70,7 +70,7 @@ namespace TGCommandLine
}
}
class RepoStatusCommand : Command
class RepoStatusCommand : ConsoleCommand
{
public RepoStatusCommand()
{
@@ -123,7 +123,7 @@ namespace TGCommandLine
}
}
class RepoResetCommand : Command
class RepoResetCommand : ConsoleCommand
{
public RepoResetCommand()
{
@@ -145,7 +145,7 @@ namespace TGCommandLine
}
}
class RepoUpdateCommand : Command
class RepoUpdateCommand : ConsoleCommand
{
public RepoUpdateCommand()
{
@@ -180,7 +180,7 @@ namespace TGCommandLine
return "<hard|merge>";
}
}
class RepoGenChangelogCommand : Command
class RepoGenChangelogCommand : ConsoleCommand
{
public RepoGenChangelogCommand()
{
@@ -200,7 +200,7 @@ namespace TGCommandLine
return "Compiles the html changelog";
}
}
class RepoPushChangelogCommand : Command
class RepoPushChangelogCommand : ConsoleCommand
{
public RepoPushChangelogCommand()
{
@@ -219,7 +219,7 @@ namespace TGCommandLine
return "Pushes the html changelog if the SSH authentication is configured correctly";
}
}
class RepoSetEmailCommand : Command
class RepoSetEmailCommand : ConsoleCommand
{
public RepoSetEmailCommand()
{
@@ -241,7 +241,7 @@ namespace TGCommandLine
return "Set the e-mail used for commits";
}
}
class RepoSetNameCommand : Command
class RepoSetNameCommand : ConsoleCommand
{
public RepoSetNameCommand()
{
@@ -263,7 +263,7 @@ namespace TGCommandLine
}
}
class RepoMergePRCommand : Command
class RepoMergePRCommand : ConsoleCommand
{
public RepoMergePRCommand()
{
@@ -298,7 +298,7 @@ namespace TGCommandLine
}
}
class RepoListPRsCommand : Command
class RepoListPRsCommand : ConsoleCommand
{
public RepoListPRsCommand()
{
@@ -325,7 +325,7 @@ namespace TGCommandLine
}
}
class RepoListBackupsCommand : Command
class RepoListBackupsCommand : ConsoleCommand
{
public RepoListBackupsCommand()
{
@@ -351,7 +351,7 @@ namespace TGCommandLine
return ExitCode.Normal;
}
}
class RepoCheckoutCommand : Command
class RepoCheckoutCommand : ConsoleCommand
{
public RepoCheckoutCommand()
{
+6 -6
View File
@@ -7,10 +7,10 @@ namespace TGCommandLine
{
class CLICommand : RootCommand
{
public CLICommand()
public CLICommand(Interface I)
{
var tmp = new List<Command> { new UpdateCommand(), new TestmergeCommand(), new RepoCommand(), new BYONDCommand(), new DMCommand(), new DDCommand(), new ConfigCommand(), new IRCCommand(), new DiscordCommand(), new AutoUpdateCommand(), new SetAutoUpdateCommand() };
if (Interface.VerifyConnection() == null && Interface.Authenticate() && Interface.AuthenticateAdmin())
if (I.VerifyConnection() == null && I.Authenticate() && I.AuthenticateAdmin())
tmp.Add(new AdminCommand());
Children = tmp.ToArray();
}
@@ -21,7 +21,7 @@ namespace TGCommandLine
base.PrintHelp();
}
}
class AutoUpdateCommand : Command
class AutoUpdateCommand : ConsoleCommand
{
public AutoUpdateCommand()
{
@@ -40,7 +40,7 @@ namespace TGCommandLine
return ExitCode.Normal;
}
}
class SetAutoUpdateCommand : Command
class SetAutoUpdateCommand : ConsoleCommand
{
public SetAutoUpdateCommand()
{
@@ -79,7 +79,7 @@ namespace TGCommandLine
}
}
class UpdateCommand : Command
class UpdateCommand : ConsoleCommand
{
public UpdateCommand()
{
@@ -140,7 +140,7 @@ namespace TGCommandLine
}
}
class TestmergeCommand : Command
class TestmergeCommand : ConsoleCommand
{
public TestmergeCommand()
{
+1
View File
@@ -44,6 +44,7 @@
<Compile Include="AdminCommands.cs" />
<Compile Include="BYONDCommands.cs" />
<Compile Include="ConfigCommands.cs" />
<Compile Include="ConsoleCommand.cs" />
<Compile Include="DDCommands.cs" />
<Compile Include="DMCommands.cs" />
<Compile Include="ChatCommands.cs" />