Skip to content

Commit

Permalink
Add connectivity check on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Jul 29, 2023
1 parent 3a82651 commit bfe32ab
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Bloxstrap/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,33 @@ protected override void OnStartup(StartupEventArgs e)
}
}

if (!IsMenuLaunch)
{
Logger.WriteLine(LOG_IDENT, "Performing connectivity check");

try
{
HttpClient.GetAsync("https://detectportal.firefox.com").Wait();
}
catch (Exception ex)
{
Logger.WriteLine(LOG_IDENT, "Connectivity check failed!");
Logger.WriteException(LOG_IDENT, ex);

Controls.ShowMessageBox(
"Bloxstrap is unable to connect to the internet. Please check your network configuration and try again.\n" +
"\n" +
"More information:\n" +
ex.InnerException!.Message,
MessageBoxImage.Error,
MessageBoxButton.OK
);

Terminate();
}
}


// check if installed
using (RegistryKey? registryKey = Registry.CurrentUser.OpenSubKey($@"Software\{ProjectName}"))
{
Expand Down

0 comments on commit bfe32ab

Please sign in to comment.