Skip to content

Commit

Permalink
Small usability improvements for the ngrok integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ngld committed Sep 8, 2020
1 parent d04534d commit 73ae931
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
20 changes: 18 additions & 2 deletions OverlayPlugin.Core/Controls/WSConfigPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public WSConfigPanel(TinyIoCContainer container)
};
}

public void Stop()
{
if (_ngrok != null && !_ngrok.HasExited)
_ngrok.Kill();
}

private void UpdateStatus(object sender, WSServer.StateChangedArgs e)
{
startBtn.Enabled = true;
Expand Down Expand Up @@ -324,6 +330,8 @@ private void RebuildOverlayOptions()

private void cbOverlay_SelectedIndexChanged(object sender, EventArgs e)
{
if (cbOverlay.SelectedIndex == -1) return;

var item = cbOverlay.Items[cbOverlay.SelectedIndex];
var preset = (IOverlayPreset) item.GetType().GetProperty("preset").GetValue(item);
if (preset == null) return;
Expand Down Expand Up @@ -459,7 +467,7 @@ private void simpStartBtn_Click(object sender, EventArgs e)
p.StartInfo.FileName = ngrokPath;
p.StartInfo.Arguments = "start -config=\"" + ngrokConfigPath + "\" wsserver";
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;
Expand Down Expand Up @@ -523,6 +531,9 @@ private void simpStartBtn_Click(object sender, EventArgs e)
if (tun["name"] != null && tun["name"].ToString() == "wsserver" && tun["public_url"] != null)
{
_ngrokPrefix = tun["public_url"].ToString().Replace("https://", "wss://");
// Update the generated URL box
cbOverlay_SelectedIndexChanged(null, null);
done = true;
break;
}
Expand All @@ -532,11 +543,16 @@ private void simpStartBtn_Click(object sender, EventArgs e)
{
simpLogBox.AppendText("Done!\r\n");
simpLogBox.AppendText("\r\n#############################################\r\nUse the URL Generator below to generate URLs for you.\r\n\r\n");
simpLogBox.AppendText("\r\nIf you know what you're using an overlay that isn't listed, here are some query strings for you:\r\n");
simpLogBox.AppendText("\r\nIf you know what you're doring or you're using an overlay that isn't listed, here are some query strings for you:\r\n");
simpLogBox.AppendText("\r\n ?HOST_PORT=" + _ngrokPrefix + "\r\n ?OVERLAY_WS=" + _ngrokPrefix + "/ws\r\n");
simpLogBox.AppendText("#############################################\r\n");
UpdateTunnelStatus(TunnelStatus.Active);
p.Exited += (_, ev) =>
{
UpdateTunnelStatus(TunnelStatus.Error);
};
} else
{
simpLogBox.AppendText("Failed!\r\n");
Expand Down
5 changes: 5 additions & 0 deletions OverlayPlugin.Core/PluginMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ public void DeInitPlugin()
try { _container.Resolve<WSServer>().Stop(); }
catch { }

if (this.wsConfigPanel != null)
{
this.wsConfigPanel.Stop();
}

if (this.wsTabPage != null && this.wsTabPage.Parent != null)
((TabControl)this.wsTabPage.Parent).TabPages.Remove(this.wsTabPage);

Expand Down

0 comments on commit 73ae931

Please sign in to comment.