25 lines
825 B
C#
25 lines
825 B
C#
|
using InnovEnergy.Lib.Utils;
|
||
|
using InnovEnergy.Lib.Victron.VictronVRM;
|
||
|
using static System.ConsoleColor;
|
||
|
|
||
|
namespace InnovEnergy.RemoteSupportConsole;
|
||
|
|
||
|
public static class VpnConnection
|
||
|
{
|
||
|
public static async Task<Int32> Open(Installation installation, IReadOnlyList<Detail> details)
|
||
|
{
|
||
|
var machineSerial = details.MachineSerial(); // DEPRECATED
|
||
|
var installationId = installation.UniqueId;
|
||
|
|
||
|
var vpnIp = await VpnInfo.LookUpIp(installationId, machineSerial); // look up by InstallationId OR machineSerial
|
||
|
|
||
|
if (String.IsNullOrWhiteSpace(vpnIp))
|
||
|
return 1;
|
||
|
|
||
|
"Starting VPN connection with ".Write();
|
||
|
installation.Name.WriteLine(Green);
|
||
|
Console.WriteLine();
|
||
|
|
||
|
return await Ssh.Interactive(vpnIp, installation.Name, "root", "22");
|
||
|
}
|
||
|
}
|