Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverseprox #72

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -363,5 +363,5 @@ MigrationBackup/
/src/Corsinvest.ProxmoxVE.Admin/wwwroot/lib
/src/Corsinvest.ProxmoxVE.Admin/appsettings.json
/src/Corsinvest.ProxmoxVE.Admin/data
setKey.ps1
create-lxc.sh
/cmd/setKey.ps1
/cmd/create-lxc.sh
7 changes: 0 additions & 7 deletions Corsinvest.ProxmoxVE.Admin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Corsinvest.ProxmoxVE.Admin"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{B81E7A2B-6A9F-42CE-BC5A-EF2BC272E0F6}"
ProjectSection(SolutionItems) = preProject
.dockerignore = .dockerignore
.gitignore = .gitignore
3rd-party-licenses.md = 3rd-party-licenses.md
Build.ps1 = Build.ps1
src\common.props = src\common.props
create-lxc.sh = create-lxc.sh
doc-utils.ps1 = doc-utils.ps1
docker-utils.ps1 = docker-utils.ps1
Dockerfile = Dockerfile
icon.png = icon.png
LICENSE = LICENSE
README.md = README.md
setKey.ps1 = setKey.ps1
Todo.md = Todo.md
EndProjectSection
EndProject
Expand Down
File renamed without changes.
30 changes: 12 additions & 18 deletions doc-utils.ps1 → cmd/doc-utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,39 @@
# SPDX-License-Identifier: AGPL-3.0-only

param(
[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[ValidateSet('build')]
[System.String]$operation
)

#Read project version
$xml = [xml](Get-Content .\src\common.props)
$xml = [xml](Get-Content ../src/common.props)
$version = $xml.Project.PropertyGroup.Version
Write-Host "Project version: $version"

Write-Host "Operation: $operation"

function Build-Doc()
{
function Build-Doc() {
Write-Host "Build Documenattion"

Write-Host "Fix version"
#replace version
$pathDoc = ".\src\Corsinvest.ProxmoxVE.Admin\wwwroot\doc\"
$indexDoc = "$pathDoc\index.adoc"

$content= [System.IO.File]::ReadAllLines($indexDoc)

For ($i=0; $i -le $content.Length; $i++) {
if ($content[$i].StartsWith(":app-version: v"))
{
$content[$i]=":app-version: v$version"
break
}
$indexDoc = "..\src\Corsinvest.ProxmoxVE.Admin\wwwroot\doc\index.adoc"
$content = Get-Content $indexDoc
For ($i = 0; $i -le $content.Length; $i++) {
if ($content[$i].StartsWith(":app-version: v")) {
$content[$i] = ":app-version: v$version"
break
}
}
Set-Content -Path $indexDoc -Value $content

#create html
Write-Host "Create html"
docker run --rm -it -v .\src\Corsinvest.ProxmoxVE.Admin\wwwroot\doc\:/documents/ asciidoctor/docker-asciidoctor asciidoctor index.adoc
docker run --rm -it -v .\..\src\Corsinvest.ProxmoxVE.Admin\wwwroot\doc\:/documents/ asciidoctor/docker-asciidoctor asciidoctor index.adoc
#docker run --rm -it -v .\src\Corsinvest.ProxmoxVE.Admin\wwwroot\doc\:/documents/ asciidoctor/docker-asciidoctor asciidoctor-pdf index.adoc
}

if($operation -eq 'build')
{
if ($operation -eq 'build') {
Build-Doc
}
16 changes: 8 additions & 8 deletions docker-utils.ps1 → cmd/docker-utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ param(
)

#Read project version
$xml = [xml](Get-Content .\src\common.props)
$xml = [xml](Get-Content ../src/common.props)
$version = $xml.Project.PropertyGroup.Version
Write-Host "Project version: $version"

Expand All @@ -28,7 +28,7 @@ function Build-Docker()

Write-Host "Build Docker cv4pve-admin"
docker rmi corsinvest/cv4pve-admin:$version --force
docker build --rm -f "Dockerfile" -t corsinvest/cv4pve-admin:$version "."
docker build --rm -f .\..\src\docker\Dockerfile -t corsinvest/cv4pve-admin:$version "..\"

#remove unused images
docker image prune -f
Expand All @@ -55,15 +55,15 @@ function Test-Docker()
corsinvest/cv4pve-admin:$version
}

if($operation -eq 'test')
{
if($operation -eq 'test')
{
Test-Docker
}
elseif($operation -eq 'build')
{
elseif($operation -eq 'build')
{
Build-Docker
}
elseif($operation -eq 'publish')
{
elseif($operation -eq 'publish')
{
Publish-Docker
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

<ItemGroup>
<PackageReference Include="Corsinvest.ProxmoxVE.AutoSnap.Api" Version="1.8.15" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.8">
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<ItemGroup>
<PackageReference Include="Corsinvest.ProxmoxVE.TelegramBot.Api" Version="1.6.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.9" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\common.props" />

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.9" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<Import Project="..\common.props" />

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.8">
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Corsinvest.AppHero.Core.MudBlazorUI" Version="0.0.108" />
<PackageReference Include="Corsinvest.AppHero.Core.MudBlazorUI" Version="0.0.110" />

<PackageReference Include="QuestPDF" Version="2023.6.0" />
<PackageReference Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2.3" />
Expand All @@ -17,9 +17,9 @@
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
<PackageReference Include="Blazored.SessionStorage" Version="2.3.0" />
<PackageReference Include="Corsinvest.ProxmoxVE.Api.Extension" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.8" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="7.22.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.9" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="7.22.4" />
<PackageReference Include="SSH.NET" Version="2020.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.9" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ private async Task FindNewNodes()
break;

case 0:
UINotifier.Show(L["All nodes have been inserted!"], UINotifierSeverity.Info);
UINotifier.Show(L["All nodes have been inserted and updated!"], UINotifierSeverity.Info);
break;

case 1:
await DataGridManager.Refresh();
UINotifier.Show(L["New nodes added! Please save."], UINotifierSeverity.Info);
UINotifier.Show(L["New nodes added and updated! Please save."], UINotifierSeverity.Info);
break;

default: break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task<int> PopulateInfoNodes(ClusterOptions clusterOptions)
var status = await client.Cluster.Status.Get();

//check new nodes
foreach (var item in status)
foreach (var item in status.Where(a=> !string.IsNullOrWhiteSpace(a.IpAddress)))
{
if (clusterOptions.GetNodeOptions(item.IpAddress, item.Name) == null)
{
Expand All @@ -79,7 +79,7 @@ public async Task<int> PopulateInfoNodes(ClusterOptions clusterOptions)
foreach (var node in clusterOptions.Nodes)
{
var nodeStatus = status.FirstOrDefault(x => x.IpAddress == node.IpAddress);
if (nodeStatus != null)
if (nodeStatus != null && nodeStatus.IsOnline)
{
var serverId = (await client.Nodes[nodeStatus.Name].Subscription.GetEx()).Serverid;
if (node.ServerId != serverId)
Expand Down
38 changes: 12 additions & 26 deletions src/Corsinvest.ProxmoxVE.Admin.Core/Subscription/Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* SPDX-FileCopyrightText: Copyright Corsinvest Srl
* SPDX-License-Identifier: AGPL-3.0-only
*/

using System.Xml.Serialization;

namespace Corsinvest.ProxmoxVE.Admin.Core.Subscription;
Expand All @@ -19,38 +18,25 @@ public class Info
public string ProductName { get; set; } = default!;

[XmlIgnore]
public DateTime RegistrationDate { get; set; } = default!;
public DateTime? RegistrationDate { get; set; } = default!;

[XmlElement("regdate")]
public string RegistrationDateString
{
get { return RegistrationDate.ToString("yyyy-MM-dd HH:mm:ss"); }
set { RegistrationDate = DateTime.Parse(value); }
get => RegistrationDate?.ToString("yyyy-MM-dd HH:mm:ss") ?? string.Empty;
set => RegistrationDate = DateTime.TryParse(value, out var date) ? date : null;
}

[XmlElement("nextduedate")]
[XmlIgnore]
public DateTime? NextDueDate { get; set; } = default!;

[XmlElement("nextduedate")]
public string NextDueDatetring
{
get => NextDueDate?.ToString("yyyy-MM-dd HH:mm:ss") ?? string.Empty;
set => NextDueDate = DateTime.TryParse(value, out var date) ? date : null;
}

[XmlElement("message")]
public string Message { get; set; } = default!;
}

/*
<status>Suspended</status>
<registeredname>Frank Lupo</registeredname>
<companyname></companyname>
<email>franklupog@gmail.com</email>
<serviceid>5</serviceid>
<productid>1</productid>
<productname>cv4pve-admin HOME</productname>
<regdate>2023-06-25 00:00:00</regdate>
<nextduedate>2023-06-27</nextduedate>
<billingcycle>Annually</billingcycle>
<validdomain>corsinvest.it,www.corsinvest.it</validdomain>
<validip>localhost</validip>
<validdirectory>A0A12C8D4C93E75AD7737C2294969A0F</validdirectory>
<configoptions></configoptions>
<customfields>Notes=|Internal Order Number=</customfields>
<addons></addons>
<md5hash></md5hash>
*/
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@using MudExtensions.Enums;
@*
@*
* SPDX-FileCopyrightText: Copyright Corsinvest Srl
* SPDX-License-Identifier: AGPL-3.0-only
*@
Expand Down Expand Up @@ -80,10 +79,12 @@
</tbody>
</MudSimpleTable>

<MudButton Variant="Variant.Filled" OnClick="@(async () => await RetrieveNodeInfo(cluster))"
Color="Color.Primary" StartIcon="@Icons.Material.Filled.Info">
<MudLoadingButton Variant="Variant.Filled" OnClick="@(async () => await RetrieveNodeInfo(cluster))"
Color="Color.Primary" StartIcon="@Icons.Material.Filled.Info" Loading="@InRetrieveNodeInfo">
@L["Retrieve cluster Info"]
</MudButton>
</MudLoadingButton>
</MudExpansionPanel>
}
</MudExpansionPanels>
</MudExpansionPanels>

<br />
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/*
* SPDX - FileCopyrightText: Copyright Corsinvest Srl
* SPDX-License-Identifier: AGPL - 3.0 - only
* SPDX-FileCopyrightText: Copyright Corsinvest Srl
* SPDX-License-Identifier: AGPL-3.0-only
*/

using Corsinvest.AppHero.Core.Options;
using Corsinvest.AppHero.Core.UI;
using Corsinvest.ProxmoxVE.Admin.Core.Options;
Expand All @@ -19,6 +18,7 @@ public partial class RenderIndex
public Dictionary<ClusterNodeOptions, Info> Checks { get; } = new();
private bool Initialized { get; set; }
private bool InSave { get; set; }
private bool InRetrieveNodeInfo { get; set; }

protected override async Task OnInitializedAsync()
{
Expand All @@ -45,18 +45,23 @@ private async Task RetrieveNodeInfo(ClusterOptions clusterOptions)
{
try
{
switch (await PveClientService.PopulateInfoNodes(clusterOptions))
InRetrieveNodeInfo = true;
var ret = await PveClientService.PopulateInfoNodes(clusterOptions);
InRetrieveNodeInfo = false;

switch (ret)
{
case -1:
UINotifier.Show(L["Credential or host not valid!"], UINotifierSeverity.Error);
break;

case 0:
UINotifier.Show(L["All nodes have been inserted!"], UINotifierSeverity.Info);
UINotifier.Show(L["All nodes have been inserted and updated!"], UINotifierSeverity.Info);
break;

case 1:
UINotifier.Show(L["New nodes added! Please save."], UINotifierSeverity.Info);
UINotifier.Show(L["New nodes added and updated! Saved."], UINotifierSeverity.Info);
WritableOptionsService.Update(AdminOptions.Value);
break;

default: break;
Expand All @@ -71,5 +76,7 @@ private async Task Save(ClusterNodeOptions nodeOptions)
WritableOptionsService.Update(AdminOptions.Value);
await SaveOnline(nodeOptions);
InSave = false;

UINotifier.Show(L["Data of node has been saved!"], UINotifierSeverity.Info);
}
}
1 change: 0 additions & 1 deletion src/Corsinvest.ProxmoxVE.Admin.Core/Subscription/Status.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* SPDX-FileCopyrightText: Copyright Corsinvest Srl
* SPDX-License-Identifier: AGPL-3.0-only
*/

namespace Corsinvest.ProxmoxVE.Admin.Core.Subscription;

public enum Status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* SPDX-FileCopyrightText: Copyright Corsinvest Srl
* SPDX-License-Identifier: AGPL-3.0-only
*/

using ApexCharts;
using System.IO;
using System.Xml.Serialization;
Expand Down Expand Up @@ -33,7 +32,7 @@ public async Task<Info> RegisterAsync(string serverId, string licenseKey)
if (response.IsSuccessStatusCode)
{
var xml = await response.Content.ReadAsStringAsync();
xml = "<?xml version='1.0' encoding='UTF-8'?><Info>" + xml + "</Info>";
xml = "<?xml version='1.0' encoding='UTF-8'?><Info>" + xml.Replace('\n', ' ') + "</Info>";
var serializer = new XmlSerializer(typeof(Info));
using var reader = new StringReader(xml);
info = (Info)serializer.Deserialize(reader)!;
Expand Down
Loading