From fd908289147ae9b2848387aac88bf951b4b871f1 Mon Sep 17 00:00:00 2001 From: Jean-Paul van Houten - Bos <10237926+vanhoutenbos@users.noreply.github.com> Date: Fri, 1 Sep 2023 10:20:00 +0200 Subject: [PATCH] =?UTF-8?q?Added=20option=20to=20use=20`--intranet`=20to?= =?UTF-8?q?=20not=20download=20or=20update=20any=20files,=E2=80=A6=20(#335?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added option to use `--intranet` to not download or update any files, this can only be done after an initial run. * Dropped some unneeded debug changes that I commited by accident * Added conventional suggestions from Github.com comments --------- Co-authored-by: Jean-Paul van Houten - Bos --- extra/exe-builder/Program.cs | 31 ++++++++-- extra/exe-builder/UptimeKuma.csproj | 94 ++++++++++++++--------------- 2 files changed, 72 insertions(+), 53 deletions(-) diff --git a/extra/exe-builder/Program.cs b/extra/exe-builder/Program.cs index 6004f6d4..d9db4d00 100644 --- a/extra/exe-builder/Program.cs +++ b/extra/exe-builder/Program.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; @@ -28,9 +28,15 @@ namespace UptimeKuma { Environment.CurrentDirectory = cwd; } + bool isIntranet = args.Contains("--intranet"); + + if (isIntranet) { + Console.WriteLine("The --intranet argument was provided, so we will not try to access the internet. The first time this application runs you'll need to run it without the --intranet param or copy the result from another machine to the intranet server."); + } + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new UptimeKumaApplicationContext()); + Application.Run(new UptimeKumaApplicationContext(isIntranet)); } } @@ -49,8 +55,9 @@ namespace UptimeKuma { private RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); + private readonly bool intranetOnly; - public UptimeKumaApplicationContext() { + public UptimeKumaApplicationContext(bool intranetOnly) { // Single instance only bool createdNew; @@ -59,6 +66,8 @@ namespace UptimeKuma { return; } + this.intranetOnly = intranetOnly; + var startingText = "Starting server..."; trayIcon = new NotifyIcon(); trayIcon.Text = startingText; @@ -98,6 +107,10 @@ namespace UptimeKuma { } void DownloadFiles() { + if (intranetOnly) { + return; + } + var form = new DownloadForm(); form.Closed += Exit; form.Show(); @@ -173,7 +186,9 @@ namespace UptimeKuma { } void CheckForUpdate(object sender, EventArgs e) { - var needUpdate = false; + if (intranetOnly) { + return; + } // Check version.json exists if (File.Exists("version.json")) { @@ -204,8 +219,12 @@ namespace UptimeKuma { } - void VisitGitHub(object sender, EventArgs e) - { + void VisitGitHub(object sender, EventArgs e) { + if (intranetOnly) { + MessageBox.Show("You have parsed in --intranet so we will not try to access the internet or visit github.com, please go to https://github.com/louislam/uptime-kuma if you want to visit github."); + return; + } + Process.Start("https://github.com/louislam/uptime-kuma"); } diff --git a/extra/exe-builder/UptimeKuma.csproj b/extra/exe-builder/UptimeKuma.csproj index ecd6a46b..ee4860dd 100644 --- a/extra/exe-builder/UptimeKuma.csproj +++ b/extra/exe-builder/UptimeKuma.csproj @@ -1,4 +1,4 @@ - + @@ -39,107 +39,107 @@ app.manifest - COPY "$(SolutionDir)bin\Debug\uptime-kuma.exe" "%UserProfile%\Desktop\uptime-kuma-win64\" + COPY "$(SolutionDir)bin\Debug\uptime-kuma.exe" "%UserProfile%\Desktop\uptime-kuma-win64\" - packages\Costura.Fody.5.7.0\lib\netstandard1.0\Costura.dll + packages\Costura.Fody.5.7.0\lib\netstandard1.0\Costura.dll - packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll + packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll - packages\Newtonsoft.Json.13.0.2\lib\net45\Newtonsoft.Json.dll + packages\Newtonsoft.Json.13.0.2\lib\net45\Newtonsoft.Json.dll - packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll + packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll - packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll - packages\System.Console.4.3.1\lib\net46\System.Console.dll + packages\System.Console.4.3.1\lib\net46\System.Console.dll - packages\System.Diagnostics.DiagnosticSource.7.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll + packages\System.Diagnostics.DiagnosticSource.7.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll - packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll + packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll - packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll + packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll - packages\System.IO.4.3.0\lib\net462\System.IO.dll + packages\System.IO.4.3.0\lib\net462\System.IO.dll - packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll - packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll + packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll - packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll + packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll - packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll - packages\System.Linq.4.3.0\lib\net463\System.Linq.dll + packages\System.Linq.4.3.0\lib\net463\System.Linq.dll - packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll + packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll - packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + packages\System.Memory.4.5.5\lib\net461\System.Memory.dll - packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll + packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll - packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll + packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll - packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll - packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll + packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll - packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll + packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll - packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll - packages\System.Runtime.Extensions.4.3.1\lib\net462\System.Runtime.Extensions.dll + packages\System.Runtime.Extensions.4.3.1\lib\net462\System.Runtime.Extensions.dll - packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll + packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll - packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll - packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll + packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll - packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll - packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll - packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll + packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll - packages\System.Text.RegularExpressions.4.3.1\lib\net463\System.Text.RegularExpressions.dll + packages\System.Text.RegularExpressions.4.3.1\lib\net463\System.Text.RegularExpressions.dll @@ -150,21 +150,21 @@ - packages\System.Xml.ReaderWriter.4.3.1\lib\net46\System.Xml.ReaderWriter.dll + packages\System.Xml.ReaderWriter.4.3.1\lib\net46\System.Xml.ReaderWriter.dll - Form + Form - DownloadForm.cs + DownloadForm.cs - DownloadForm.cs + DownloadForm.cs ResXFileCodeGenerator @@ -176,7 +176,7 @@ Resources.resx - favicon.ico + favicon.ico @@ -193,18 +193,18 @@ - - + + - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. - - - - - + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. + + + + +