From 05a5aab7bca46a5c2105339c297b880f5191e0ae Mon Sep 17 00:00:00 2001 From: Andy Funk Date: Thu, 16 Jan 2025 15:24:58 -0700 Subject: [PATCH 1/4] replace goal/update ExecCmd refs --- FUNC/Controllers/GoalController.cs | 29 ++++++++++++++++++----------- webui/src/components/Settings.vue | 2 -- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/FUNC/Controllers/GoalController.cs b/FUNC/Controllers/GoalController.cs index 1263676..8476469 100644 --- a/FUNC/Controllers/GoalController.cs +++ b/FUNC/Controllers/GoalController.cs @@ -1,3 +1,5 @@ +using System.Formats.Tar; +using System.IO.Compression; using System.Runtime.InteropServices; using FUNC.Models; using Microsoft.AspNetCore.Mvc; @@ -66,6 +68,7 @@ public async Task> GoalUpdate(Models.Release model) { try { + string? url = null; if (IsWindows()) { string workspaceName = "GalaxyPay"; @@ -81,9 +84,7 @@ public async Task> GoalUpdate(Models.Release model) { release = await client.Repository.Release.Get(workspaceName, repositoryName, model.Name); } - var url = release?.Assets.FirstOrDefault(a => a.Name == "node.tar.gz")?.BrowserDownloadUrl; - if (url == null) return BadRequest(); - await Utils.ExecCmd($"curl -L -o {Utils.appDataDir}/node.tar.gz {url}"); + url = release?.Assets.FirstOrDefault(a => a.Name == "node.tar.gz")?.BrowserDownloadUrl; } else if (IsLinux()) { @@ -95,7 +96,6 @@ public async Task> GoalUpdate(Models.Release model) var client = new GitHubClient(new ProductHeaderValue(repositoryName)); var latestInfo = await client.Repository.Release.GetLatest(workspaceName, repositoryName); - string? url = null; if (RuntimeInformation.OSArchitecture == Architecture.Arm64) { url = latestInfo.Assets.FirstOrDefault(a => a.Name.Contains("node_stable_linux-arm64") @@ -106,8 +106,6 @@ public async Task> GoalUpdate(Models.Release model) url = latestInfo.Assets.FirstOrDefault(a => a.Name.Contains("node_stable_linux-amd64") && a.Name.EndsWith("tar.gz"))?.BrowserDownloadUrl; } - if (url == null) return BadRequest(); - await Utils.ExecCmd($"wget -L -O {Utils.appDataDir}/node.tar.gz {url}"); } else if (IsMacOS()) { @@ -119,14 +117,23 @@ public async Task> GoalUpdate(Models.Release model) var client = new GitHubClient(new ProductHeaderValue(repositoryName)); var latestInfo = await client.Repository.Release.GetLatest(workspaceName, repositoryName); - string? url = latestInfo.Assets.FirstOrDefault(a => a.Name.Contains("node_stable_darwin") + url = latestInfo.Assets.FirstOrDefault(a => a.Name.Contains("node_stable_darwin") && a.Name.EndsWith("tar.gz"))?.BrowserDownloadUrl; - if (url == null) return BadRequest(); - await Utils.ExecCmd($"curl -L -o {Utils.appDataDir}/node.tar.gz {url}"); } - await Utils.ExecCmd($"tar -zxf {Utils.appDataDir}/node.tar.gz -C {Utils.appDataDir} bin"); - await Utils.ExecCmd($"rm {Utils.appDataDir}/node.tar.gz"); + string filePath = Path.Combine(Utils.appDataDir, "node.tar.gz"); + using var httpClient = new HttpClient(); + using var s = await httpClient.GetStreamAsync(url); + using FileStream fs = new(filePath, System.IO.FileMode.OpenOrCreate); + await s.CopyToAsync(fs); + fs.Dispose(); + + using FileStream rfs = new(filePath, System.IO.FileMode.Open, FileAccess.Read); + using GZipStream gz = new(rfs, CompressionMode.Decompress, leaveOpen: true); + await TarFile.ExtractToDirectoryAsync(gz, Utils.appDataDir, true); + rfs.Dispose(); + + System.IO.File.Delete(filePath); return Ok(); } diff --git a/webui/src/components/Settings.vue b/webui/src/components/Settings.vue index 00e68dc..e9fd75b 100644 --- a/webui/src/components/Settings.vue +++ b/webui/src/components/Settings.vue @@ -123,8 +123,6 @@ async function getVersion() { if (!init) { init = true; updateNodeLatest(true); - } else { - throw Error("Download Failed"); } } From e243f340be5766d15d02c99c3f75ae8d49ab526b Mon Sep 17 00:00:00 2001 From: Andy Funk Date: Thu, 16 Jan 2025 15:25:10 -0700 Subject: [PATCH 2/4] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b21c42a..7ea661b 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ Here's how to do it: - This should **ONLY** be done on a local network - **DO NOT** open these ports to the internet -- If you want to be able to use WalletConnect wallets (e.g. Defly, Pera) while accessing the site via IP, you'll need to use port 3537 which serves the site with a self-signed cert over HTTPS. You'll also need "Allow Insecure Content" for the site in your browser settings so that it can communicate to your node over HTTP. +- If you want to be able to use WalletConnect wallets (e.g. Defly, Pera) or "copy to clipboard" buttons while accessing the site remotely, you'll need to use port 3537 which serves the site with a self-signed cert over HTTPS. You'll also need "Allow Insecure Content" for the site in your browser settings so that it can communicate to your node over HTTP. ## Build (for Developers) From e38ac418df898d80e8fb1987f7ce959b201fe047 Mon Sep 17 00:00:00 2001 From: Andy Funk Date: Thu, 16 Jan 2025 16:33:28 -0700 Subject: [PATCH 3/4] fix: isIncentiveReady --- .github/workflows/go.yml | 2 +- FUNC.iss | 2 +- create-package-deb.sh | 2 +- create-package-pkg.sh | 2 +- deb/amd64/control | 2 +- deb/arm64/control | 2 +- webui/package.json | 2 +- webui/src/components/Node.vue | 4 +--- 8 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 97f3eb3..97b55eb 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -266,5 +266,5 @@ jobs: uses: ncipollo/release-action@v1 with: allowUpdates: true - tag: v3.2.0 + tag: v3.2.1 artifacts: "Output/*" diff --git a/FUNC.iss b/FUNC.iss index 82a5cbf..522ff38 100644 --- a/FUNC.iss +++ b/FUNC.iss @@ -2,7 +2,7 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "FUNC" -#define MyAppVersion "3.2.0" +#define MyAppVersion "3.2.1" #define MyAppPublisher "Galaxy Pay, LLC" #define MyAppPublisherURL "https://galaxy-pay.com" #define MyPublishPath "publish" diff --git a/create-package-deb.sh b/create-package-deb.sh index 9170ac0..1fd1b48 100755 --- a/create-package-deb.sh +++ b/create-package-deb.sh @@ -1,6 +1,6 @@ rm -r Output -PKG=Output/func_3.2.0_linux-$1 +PKG=Output/func_3.2.1_linux-$1 mkdir -p $PKG/lib/systemd/system mkdir -p $PKG/opt/func diff --git a/create-package-pkg.sh b/create-package-pkg.sh index 5397413..d4bd6a4 100755 --- a/create-package-pkg.sh +++ b/create-package-pkg.sh @@ -5,4 +5,4 @@ pkgbuild --root publish \ --install-location /opt/func \ --scripts pkg/scripts \ --identifier func.app \ - Output/func_3.2.0_darwin-$1.pkg + Output/func_3.2.1_darwin-$1.pkg diff --git a/deb/amd64/control b/deb/amd64/control index ee5c782..c3a1f4d 100644 --- a/deb/amd64/control +++ b/deb/amd64/control @@ -1,5 +1,5 @@ Package: func -Version: 3.2.0 +Version: 3.2.1 Section: base Priority: optional Architecture: amd64 diff --git a/deb/arm64/control b/deb/arm64/control index b4b1dd2..9055d64 100644 --- a/deb/arm64/control +++ b/deb/arm64/control @@ -1,5 +1,5 @@ Package: func -Version: 3.2.0 +Version: 3.2.1 Section: base Priority: optional Architecture: arm64 diff --git a/webui/package.json b/webui/package.json index 0f96412..f2ff7f9 100644 --- a/webui/package.json +++ b/webui/package.json @@ -1,6 +1,6 @@ { "name": "func-webui", - "version": "3.2.0", + "version": "3.2.1", "scripts": { "dev": "vite", "build": "vite build", diff --git a/webui/src/components/Node.vue b/webui/src/components/Node.vue index f348691..3b9dc3e 100644 --- a/webui/src/components/Node.vue +++ b/webui/src/components/Node.vue @@ -330,9 +330,7 @@ const algodClient = computed(() => { watch( () => algodStatus.value, (val) => { - if (!val?.["last-version"].includes("/925a464")) { - store.isIncentiveReady = true; - } + if (val?.["last-round"] >= 46512890) store.isIncentiveReady = true; } ); From 3a3cef6506751d65903a26fa341ffe9c32f10d23 Mon Sep 17 00:00:00 2001 From: Andy Funk Date: Fri, 17 Jan 2025 11:43:19 -0700 Subject: [PATCH 4/4] replace DownloadExtractReti ExecCmd refs --- FUNC/Controllers/RetiController.cs | 60 +++++++++++++----------------- FUNC/Node.cs | 5 ++- 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/FUNC/Controllers/RetiController.cs b/FUNC/Controllers/RetiController.cs index 29200a2..e1400f2 100644 --- a/FUNC/Controllers/RetiController.cs +++ b/FUNC/Controllers/RetiController.cs @@ -1,3 +1,5 @@ +using System.Formats.Tar; +using System.IO.Compression; using System.Runtime.InteropServices; using FUNC.Models; using Microsoft.AspNetCore.Mvc; @@ -179,45 +181,35 @@ private static async Task DownloadExtractReti() Directory.CreateDirectory(Path.Combine(Utils.appDataDir, "reti")); + var pattern = (IsWindows() ? "windows-amd64.zip" + : IsLinux() ? (RuntimeInformation.OSArchitecture == Architecture.Arm64 ? "linux-arm64.tar.gz" : "linux-amd64.tar.gz") + : IsMacOS() ? (RuntimeInformation.OSArchitecture == Architecture.Arm64 ? "darwin-arm64.tar.gz" : "darwin-amd64.tar.gz") + : null) ?? throw new Exception("Binary Not Found"); + var asset = latest.Assets.FirstOrDefault(a => a.Name.EndsWith(pattern)) ?? throw new Exception("Binary Not Found"); + + string filePath = Path.Combine(Utils.appDataDir, asset.Name); + string destDir = Path.Combine(Utils.appDataDir, "reti"); + using var httpClient = new HttpClient(); + using var s = await httpClient.GetStreamAsync(asset.BrowserDownloadUrl); + using FileStream fs = new(filePath, System.IO.FileMode.OpenOrCreate); + await s.CopyToAsync(fs); + fs.Dispose(); + if (IsWindows()) { - var url = (latest.Assets.FirstOrDefault(a => a.Name.EndsWith("windows-amd64.zip"))?.BrowserDownloadUrl) - ?? throw new Exception("Binary Not Found"); - await Utils.ExecCmd($"curl -L -o {Utils.appDataDir}/reti.zip {url}"); - await Utils.ExecCmd($"tar -xf {Utils.appDataDir}/reti.zip -C {Path.Combine(Utils.appDataDir, "reti")}"); + DirectoryInfo di = new(destDir); + foreach (FileInfo file in di.GetFiles()) file.Delete(); + ZipFile.ExtractToDirectory(filePath, destDir); } - else if (IsLinux()) + else { - string? url = null; - if (RuntimeInformation.OSArchitecture == Architecture.Arm64) - { - url = latest.Assets.FirstOrDefault(a => a.Name.EndsWith("linux-arm64.tar.gz"))?.BrowserDownloadUrl - ?? throw new Exception("Binary Not Found"); - } - else - { - url = latest.Assets.FirstOrDefault(a => a.Name.EndsWith("linux-amd64.tar.gz"))?.BrowserDownloadUrl - ?? throw new Exception("Binary Not Found"); - } - await Utils.ExecCmd($"wget -L -O {Utils.appDataDir}/reti.tar.gz {url}"); - await Utils.ExecCmd($"tar -zxf {Utils.appDataDir}/reti.tar.gz -C {Path.Combine(Utils.appDataDir, "reti")}"); - } - else if (IsMacOS()) - { - string? url = null; - if (RuntimeInformation.OSArchitecture == Architecture.Arm64) - { - url = latest.Assets.FirstOrDefault(a => a.Name.EndsWith("darwin-arm64.tar.gz"))?.BrowserDownloadUrl - ?? throw new Exception("Binary Not Found"); - } - else - { - url = latest.Assets.FirstOrDefault(a => a.Name.EndsWith("darwin-amd64.tar.gz"))?.BrowserDownloadUrl - ?? throw new Exception("Binary Not Found"); - } - await Utils.ExecCmd($"curl -L -o {Utils.appDataDir}/reti.tar.gz {url}"); - await Utils.ExecCmd($"tar -zxf {Utils.appDataDir}/reti.tar.gz -C {Path.Combine(Utils.appDataDir, "reti")}"); + using FileStream rfs = new(filePath, System.IO.FileMode.Open, FileAccess.Read); + using GZipStream gz = new(rfs, CompressionMode.Decompress, leaveOpen: true); + await TarFile.ExtractToDirectoryAsync(gz, destDir, true); + rfs.Dispose(); } + + System.IO.File.Delete(filePath); } } } diff --git a/FUNC/Node.cs b/FUNC/Node.cs index b81eef4..e3edfb4 100644 --- a/FUNC/Node.cs +++ b/FUNC/Node.cs @@ -1,4 +1,5 @@ -using FUNC.Models; +using System.Formats.Tar; +using FUNC.Models; using Newtonsoft.Json.Linq; using static System.OperatingSystem; @@ -9,7 +10,7 @@ public class Node private static async Task ExtractTemplate(string name) { string templatePath = Path.Combine(AppContext.BaseDirectory, "Templates", $"{name}.tar"); - await Utils.ExecCmd($"tar -xf \"{templatePath}\" -C {Utils.NodeDataParent(name)}"); + await TarFile.ExtractToDirectoryAsync(templatePath, Utils.NodeDataParent(name), true); } public static async Task Get(string name)