private static void ParsePostInitArgs(IEnumerable <string> args) { if (args == null) { ASF.ArchiLogger.LogNullError(nameof(args)); return; } foreach (string arg in args) { switch (arg) { case "": break; case "--server": IPC.Start(); break; default: if (arg.StartsWith("--", StringComparison.Ordinal)) { if (arg.StartsWith("--cryptkey=", StringComparison.Ordinal) && (arg.Length > 11)) { CryptoHelper.SetEncryptionKey(arg.Substring(11)); } } break; } } }
private static async Task InitGlobalDatabaseAndServices() { string globalDatabaseFile = Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalDatabaseFileName); if (!File.Exists(globalDatabaseFile)) { ASF.ArchiLogger.LogGenericInfo(Strings.Welcome); await Task.Delay(10 * 1000).ConfigureAwait(false); ASF.ArchiLogger.LogGenericWarning(Strings.WarningPrivacyPolicy); await Task.Delay(5 * 1000).ConfigureAwait(false); } GlobalDatabase = await GlobalDatabase.Load(globalDatabaseFile).ConfigureAwait(false); if (GlobalDatabase == null) { ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorDatabaseInvalid, globalDatabaseFile)); await Task.Delay(5 * 1000).ConfigureAwait(false); await Exit(1).ConfigureAwait(false); return; } if (Debugging.IsUserDebugging) { ASF.ArchiLogger.LogGenericDebug(SharedInfo.GlobalDatabaseFileName + ": " + JsonConvert.SerializeObject(GlobalDatabase, Formatting.Indented)); } // If debugging is on, we prepare debug directory prior to running if (GlobalConfig.Debug) { Logging.EnableTraceLogging(); if (Directory.Exists(SharedInfo.DebugDirectory)) { try { Directory.Delete(SharedInfo.DebugDirectory, true); await Task.Delay(1000).ConfigureAwait(false); // Dirty workaround giving Windows some time to sync } catch (IOException e) { ASF.ArchiLogger.LogGenericException(e); } } Directory.CreateDirectory(SharedInfo.DebugDirectory); DebugLog.AddListener(new Debugging.DebugListener()); DebugLog.Enabled = true; } WebBrowser.Init(); WebBrowser = new WebBrowser(ASF.ArchiLogger, GlobalConfig.WebProxy, true); if (GlobalConfig.IPC && (GlobalConfig.IPCPrefixes.Count > 0)) { IPC.Start(GlobalConfig.IPCPrefixes); } }
private static void ParsePostInitArgs(IReadOnlyCollection <string> args) { if (args == null) { ASF.ArchiLogger.LogNullError(nameof(args)); return; } bool cryptKeyNext = false; foreach (string arg in args) { switch (arg) { case "": break; case "--path": if (cryptKeyNext) { goto default; } // Not handled in PostInit break; case "--cryptkey": if (cryptKeyNext) { goto default; } cryptKeyNext = true; break; case "--server": if (cryptKeyNext) { goto default; } IPC.Start(GlobalConfig.IPCHost, GlobalConfig.IPCPort); break; case "--service": if (cryptKeyNext) { goto default; } ServiceMode = true; break; default: if (cryptKeyNext) { cryptKeyNext = false; HandleCryptKeyArgument(arg); } else if (arg.StartsWith("--", StringComparison.Ordinal)) { if (arg.StartsWith("--cryptkey=", StringComparison.Ordinal) && (arg.Length > 11)) { HandleCryptKeyArgument(arg.Substring(11)); } } break; } } }
private static void ParsePostInitArgs(IReadOnlyCollection <string> args) { if (args == null) { ASF.ArchiLogger.LogNullError(nameof(args)); return; } bool cryptKeyNext = false; foreach (string arg in args) { switch (arg) { case "--cryptkey" when !cryptKeyNext: cryptKeyNext = true; break; case "--no-restart" when !cryptKeyNext: RestartAllowed = false; break; case "--process-required" when !cryptKeyNext: ProcessRequired = true; break; case "--server" when !cryptKeyNext: // TODO: Deprecate further in the next version ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningDeprecated, "--server", "GlobalConfig.IPC")); ProcessRequired = true; if (GlobalConfig.IPCPrefixes.Count > 0) { IPC.Start(GlobalConfig.IPCPrefixes); } break; case "--service" when !cryptKeyNext: // TODO: Deprecate further in the next version ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningDeprecated, "--service", "--no-restart --process-required --system-required")); RestartAllowed = false; ProcessRequired = true; SystemRequired = true; break; case "--system-required" when !cryptKeyNext: SystemRequired = true; break; default: if (cryptKeyNext) { cryptKeyNext = false; HandleCryptKeyArgument(arg); } else if ((arg.Length > 11) && arg.StartsWith("--cryptkey=", StringComparison.Ordinal)) { HandleCryptKeyArgument(arg.Substring(11)); } break; } } }