From 85cc051135fd778d71c725ded039428ea3f9e1d2 Mon Sep 17 00:00:00 2001 From: gitercn <53464166+gitercn@users.noreply.github.com> Date: Wed, 18 Nov 2020 00:55:21 +0800 Subject: [PATCH] add an option to specify the proxy in fetched .vv file --- src/Corsinvest.ProxmoxVE.Pepper/Program.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Corsinvest.ProxmoxVE.Pepper/Program.cs b/src/Corsinvest.ProxmoxVE.Pepper/Program.cs index 764228a..816e964 100644 --- a/src/Corsinvest.ProxmoxVE.Pepper/Program.cs +++ b/src/Corsinvest.ProxmoxVE.Pepper/Program.cs @@ -38,6 +38,11 @@ namespace Corsinvest.ProxmoxVE.Pepper "Executable SPICE client remote viewer", CommandOptionType.SingleValue) .DependOn(app, CommandOptionExtension.HOST_OPTION_NAME); + + var optFetchedVVProxy = app.Option("--fetched-vv-proxy", + "Replace the proxy value in the fetched *.vv file. This is used whe you using reverse proxy to access Proxmox VE and redirected the default 3128 port to another port. Then you need to specify it http://[host]:[port]", + CommandOptionType.SingleValue); + optRemoteViewer.Accepts().ExistingFile(); app.OnExecute(() => @@ -51,6 +56,19 @@ namespace Corsinvest.ProxmoxVE.Pepper if (ret) { var fileName = Path.GetTempFileName().Replace(".tmp", ".vv"); + if (optFetchedVVProxy.HasValue()) + { + string[] lines = content.Split("\n"); + for (int i = 0; i < lines.Length; i++) + { + if (lines[i].StartsWith("proxy=")) + { + lines[i] = "proxy=" + optFetchedVVProxy.Value(); + } + } + string contentmod = string.Join("\n", lines); + content = contentmod; + } File.WriteAllText(fileName, content); var startInfo = new ProcessStartInfo { @@ -101,4 +119,4 @@ namespace Corsinvest.ProxmoxVE.Pepper return app.ExecuteConsoleApp(args); } } -} \ No newline at end of file +}