Added option to use `--intranet` to not download or update any files,… (#3350)

* 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 <jeanpaul.vhouten@koop.overheid.nl>
pull/3670/head
Jean-Paul van Houten - Bos 1 year ago committed by GitHub
parent 42bba73ffe
commit fd90828914
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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");
}

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\Costura.Fody.5.7.0\build\Costura.Fody.props" Condition="Exists('packages\Costura.Fody.5.7.0\build\Costura.Fody.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

Loading…
Cancel
Save