1
0
Fork 0
mirror of https://github.com/Corsinvest/cv4pve-pepper.git synced 2025-03-09 15:39:57 +00:00

add an option to specify the proxy in fetched .vv file

This commit is contained in:
gitercn 2020-11-18 00:55:21 +08:00
parent a08c9d7852
commit 85cc051135

View file

@ -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);
}
}
}
}