private async Task <bool> StartUpNewProxy(CancellationToken token) { var hasStarted = StartProcess(); this.Output = ReadOutput(token); token.ThrowIfCancellationRequested(); if (!Output.EndsWith(SuccessfullConnectionText)) { throw new SauceConnectProxyException(Output); } this.information = await WaitForTunnelInformation(token); this.information.Process = process; return(hasStarted); }
private async Task ReleaseResources() { if (previouslyRunning) { return; } information = await GetTunnelInformation(default(CancellationToken)); if (information != null) { await this.sauceConnectRestClient.DeleteTunnelAsync(information?.Id, default(CancellationToken)).ConfigureAwait(false); } if ((!process?.HasExited).GetValueOrDefault()) { process?.Kill(); process?.WaitForExit(); } }
private bool QueryExistingProxyAndSetValues(TunnelInformation info) { this.information = info; var start = this.information.Metadata.Command.IndexOf('-'); var parameters = this.information.Metadata.Command.Trim().Substring(start).Split(' '); if (parameters.Length % 2 != 0) { throw new SauceConnectProxyException($"Could not parse metadata parameters from tunnel information, because there is not an even number or arguments: '{info.Metadata.Command}'"); } IDictionary <string, string> commandLineParameters = new Dictionary <string, string>(); for (var i = 0; i < parameters.Length; i += 2) { commandLineParameters.Add(parameters[i], parameters[i + 1]); } this.port = int.Parse(SearchForParameter(commandLineParameters, info, PortFlagName, "-P")); this.previouslyRunning = true; return(true); }
public void SetContext(TunnelInformation oit, int area) { _dt = oit; _areaid1 = area; DataContext = oit; }
public EventArgsAddTunnel(TunnelInformation info) { AddTunnelInfo = info; }
public EventArgsSelectTerminal(TunnelInformation info) { SelectTerminalInfo = info; }
public void SetContext(TunnelInformation oit) { _dt = oit; DataContext = oit; }
private static string SearchForParameter(IDictionary <string, string> commandLineParameters, TunnelInformation info, string fullFlag, string shortFlag, bool throwIfMissing = true) { if (!commandLineParameters.TryGetValue(fullFlag, out var parameter) && !commandLineParameters.TryGetValue(shortFlag, out parameter) && throwIfMissing) { throw new SauceConnectProxyException($"Proxy seems to be open but could not locate either flag [{fullFlag}, {shortFlag}] in the launch command '{info.Metadata?.Command}"); } return(parameter); }