fixed trimming bug in get_cert, its 75mb now

This commit is contained in:
Kim 2023-03-30 08:30:40 +02:00
parent eb03329441
commit 46db92fee5
3 changed files with 25 additions and 12 deletions

View File

@ -1,17 +1,17 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
#pragma warning disable CS8618
namespace InnovEnergy.App.OpenVpnCertificatesServer; namespace InnovEnergy.App.OpenVpnCertificatesServer;
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
internal class AccToken internal class AccToken
{ {
public String token { get; init; } public String bearer { get; init; } = "";
public String bearer { get; init; }
public UInt64 idUser { get; init; } public UInt64 idUser { get; init; }
public String verification_mode { get; init; } public String verification_mode { get; init; } = "password";
public String idAccessToken { get; init; } public Boolean verification_sent { get; init; } = false;
public Boolean verification_sent { get; init; } public Boolean success { get; init; } = false;
public Boolean success { get; init; } public String token { get; init; } = "";
public String idAccessToken { get; init; } = "";
} }

View File

@ -19,4 +19,8 @@
</None> </None>
</ItemGroup> </ItemGroup>
<PropertyGroup>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
</Project> </Project>

View File

@ -36,10 +36,11 @@ public static class Program
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 static AccToken ReadAccessToken() private static AccToken? ReadAccessToken()
{ {
var content = File.ReadAllText("./token.json"); var content = File.ReadAllText("./token.json");
return JsonSerializer.Deserialize<AccToken>(content)!;
return JsonSerializer.Deserialize<AccToken>(content);
} }
@ -146,9 +147,14 @@ public static class Program
//var installationName = await LookupInstallationNameByUniqueId(ccdName); //var installationName = await LookupInstallationNameByUniqueId(ccdName);
var token = ReadAccessToken(); var token = ReadAccessToken();
using var vrm = VrmAccount.Token(token.idUser, token.token);
var vrm = VrmAccount.Token(token.idUser, token.token);
var installations = await vrm.GetInstallations(); var installations = await vrm.GetInstallations();
var installationName = installations var installationName = installations
.Where(i => i.UniqueId == uniqueId) .Where(i => i.UniqueId == uniqueId)
.Select(i => i.Name) .Select(i => i.Name)
@ -163,7 +169,9 @@ public static class Program
{ {
Console.WriteLine($"looking up {ccdName} on VRM"); Console.WriteLine($"looking up {ccdName} on VRM");
var token = ReadAccessToken(); var token = ReadAccessToken();
using var vrm = VrmAccount.Token(token.idUser, token.token); using var vrm = VrmAccount.Token(token.idUser, token.token);
var installations = await vrm.GetInstallations(); var installations = await vrm.GetInstallations();
foreach (var installation in installations) foreach (var installation in installations)
@ -176,6 +184,7 @@ public static class Program
return (ccdName, installation.Name); return (ccdName, installation.Name);
} }
Console.WriteLine($"not found");
return null; return null;
} }