Wip test commit
This commit is contained in:
parent
50036daa78
commit
610aa05a38
|
@ -1,5 +1,8 @@
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
using Flurl;
|
using Flurl;
|
||||||
using ICSharpCode.SharpZipLib.Tar;
|
using ICSharpCode.SharpZipLib.Tar;
|
||||||
using InnovEnergy.App.OpenVpnCertificatesServer.PKI;
|
using InnovEnergy.App.OpenVpnCertificatesServer.PKI;
|
||||||
|
@ -18,6 +21,7 @@ namespace InnovEnergy.App.OpenVpnCertificatesServer;
|
||||||
// quotes!!
|
// quotes!!
|
||||||
// wget 'http://localhost:4000/get_cert?name=MYNAME&pw=MwBRbQb3QaX7l9XIaakq'
|
// wget 'http://localhost:4000/get_cert?name=MYNAME&pw=MwBRbQb3QaX7l9XIaakq'
|
||||||
|
|
||||||
|
[SuppressMessage("Trimming", "IL2026:Members annotated with \'RequiresUnreferencedCodeAttribute\' require dynamic access otherwise can break functionality when trimming application code")]
|
||||||
public static class Program
|
public static class Program
|
||||||
{
|
{
|
||||||
// TODO: use fody weaver to obfuscate strings?
|
// TODO: use fody weaver to obfuscate strings?
|
||||||
|
@ -25,13 +29,13 @@ public static class Program
|
||||||
private const String VpnSubnet = "10.2.";
|
private const String VpnSubnet = "10.2.";
|
||||||
private const String VpnGateway = "10.2.0.1";
|
private const String VpnGateway = "10.2.0.1";
|
||||||
|
|
||||||
private const String VpnDir = "/etc/openvpn/server/Salino";
|
private const String VpnDir = "/etc/openvpn/server/Salino";
|
||||||
private const String CcdDir = VpnDir + "/ccd";
|
private const String CcdDir = VpnDir + "/ccd";
|
||||||
private const String CertsDir = VpnDir + "/certs";
|
private const String CertsDir = VpnDir + "/certs";
|
||||||
private const String Endpoint = "http://localhost:4000/";
|
private const String Endpoint = "http://localhost:4000/";
|
||||||
private const String VrmUser = "victron@innov.energy";
|
|
||||||
private const String VrmPwd = "NnoVctr201002";
|
private static readonly AccToken AccToken = JsonSerializer.Deserialize<AccToken>(File.OpenRead("./token.json"))!; //"d4179e69413ad8c507e0965a55bb90fe712184af9c81c196b9d19db5bb083d5f";
|
||||||
private const String ManualPw = "MwBRbQb3QaX7l9XIaakq";
|
private const String ManualPw = "MwBRbQb3QaX7l9XIaakq";
|
||||||
|
|
||||||
private const String QueryPath = "/get_cert";
|
private const String QueryPath = "/get_cert";
|
||||||
private const String NameQueryParam = "name";
|
private const String NameQueryParam = "name";
|
||||||
|
@ -134,7 +138,7 @@ public static class Program
|
||||||
|
|
||||||
//var installationName = await LookupInstallationNameByUniqueId(ccdName);
|
//var installationName = await LookupInstallationNameByUniqueId(ccdName);
|
||||||
|
|
||||||
using var vrm = await VrmAccount.Login(VrmUser, VrmPwd); // TODO: use token
|
using var vrm = VrmAccount.Token(AccToken.Id, AccToken.Token);
|
||||||
var installations = await vrm.GetInstallations();
|
var installations = await vrm.GetInstallations();
|
||||||
|
|
||||||
var installationName = installations
|
var installationName = installations
|
||||||
|
@ -151,7 +155,7 @@ public static class Program
|
||||||
{
|
{
|
||||||
Console.WriteLine($"looking up {ccdName} on VRM");
|
Console.WriteLine($"looking up {ccdName} on VRM");
|
||||||
|
|
||||||
using var vrm = await VrmAccount.Login(VrmUser, VrmPwd); // TODO: use token
|
using var vrm = VrmAccount.Token(AccToken.Id, AccToken.Token);
|
||||||
var installations = await vrm.GetInstallations();
|
var installations = await vrm.GetInstallations();
|
||||||
|
|
||||||
foreach (var installation in installations)
|
foreach (var installation in installations)
|
||||||
|
@ -266,3 +270,9 @@ public static class Program
|
||||||
return $"{VpnSubnet}{hi}.{lo}";
|
return $"{VpnSubnet}{hi}.{lo}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal interface AccToken
|
||||||
|
{
|
||||||
|
public String Token { get; init; }
|
||||||
|
public UInt64 Id { get; init; }
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
## USAGE: ./newToken.sh -u USERNAME -p PASSWORD
|
||||||
|
|
||||||
|
|
||||||
|
while getopts u:p: flag
|
||||||
|
do
|
||||||
|
case "${flag}" in
|
||||||
|
u) username=${OPTARG};;
|
||||||
|
p) password=${OPTARG};;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
curl --request POST \
|
||||||
|
--url https://vrmapi.victronenergy.com/v2/auth/login \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data '{
|
||||||
|
"username": '$username',
|
||||||
|
"password": '$password',
|
||||||
|
}' > token.json
|
Loading…
Reference in New Issue