From 3631fac29469f4b14873ef4f55f499221e0f6456 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:12:24 +0100 Subject: [PATCH 01/56] Fix: Dashboard: Network connection check stuck after several refreshes (B1) A refresh during a running check repeats the check once it has finished instead of canceling it (the cancellation tokens of overlapping refreshes were disposed by each other). Minimum duration like the IP API widgets. Co-Authored-By: Claude Opus 5.5 --- .../NetworkConnectionWidgetViewModel.cs | 184 +++++------------- Website/docs/changelog/next-release.md | 4 + 2 files changed, 58 insertions(+), 130 deletions(-) diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index f68e6e5194..f6ace14900 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -5,7 +5,6 @@ using System.Net; using System.Net.Http; using System.Text.RegularExpressions; -using System.Threading; using System.Threading.Tasks; using System.Windows.Input; using log4net; @@ -116,14 +115,14 @@ private set /// /// Gets the command to check connections. /// - public ICommand CheckCommand => new RelayCommand(_ => Check()); + public ICommand CheckCommand => new RelayCommand(_ => Check(), _ => !IsChecking); #endregion #region Methods /// - /// Checks the network connections. + /// Checks the network connections. If a check is already running, it is repeated once it has finished. /// public void Check() { @@ -131,96 +130,60 @@ public void Check() } /// - /// The cancellation token source. + /// A check was requested while another one was running (e.g. a network change during a check). The running check + /// is repeated once it has finished, so the result shows the latest state. Only used on the UI thread. /// - private CancellationTokenSource _cancellationTokenSource; - - /// - /// The check task. - /// - private Task _checkTask = Task.CompletedTask; - - /// - /// Monotonically increasing id of the current check run. None of the underlying detection/DNS - /// calls support real mid-flight cancellation (see ), so a superseded run - /// can still be executing in the background after a newer run has started. Every write to a - /// is guarded by comparing against this field, so a superseded - /// run's results are silently discarded instead of racing with the current run's writes. - /// - private long _generation; + private bool _recheckPending; /// /// Checks the network connections asynchronously. /// private async Task CheckAsync() { - Log.Info("Checking network connection..."); - - // Bump the generation immediately so a still-running previous check stops writing - // its results as soon as possible, even before it notices the cancellation below. - var generation = Interlocked.Increment(ref _generation); - - // Cancel previous checks if running - if (!_checkTask.IsCompleted) + if (IsChecking) { - Log.Info("Cancelling previous checks..."); - await _cancellationTokenSource.CancelAsync(); - - try - { - await _checkTask; - } - catch (OperationCanceledException) - { - Log.Info("Task was cancelled from previous checks."); - } - finally - { - _cancellationTokenSource.Dispose(); - } + _recheckPending = true; + return; } - _cancellationTokenSource = new CancellationTokenSource(); - var wasCanceled = false; - IsChecking = true; try { - _checkTask = RunTask(_cancellationTokenSource.Token, generation); - await _checkTask; + do + { + _recheckPending = false; + + Log.Info("Checking network connection..."); + + // Takes at least the refresh interval, so the reload animation is visible and the check can't be + // spammed - the checks run at the same time + await TaskHelper.WithMinimumDurationAsync(RunTask, GlobalStaticConfiguration.ApplicationUIRefreshInterval); + + Log.Info("Network connection check completed."); + } while (_recheckPending); } - catch (OperationCanceledException) + catch (Exception ex) { - wasCanceled = true; - Log.Info("Task was cancelled from current checks."); + Log.Error("Network connection check failed.", ex); } finally { IsChecking = false; - _cancellationTokenSource.Dispose(); - - if (!wasCanceled) - Log.Info("Network connection check completed."); } } /// /// Runs the check tasks. /// - /// The cancellation token. - /// The id of this check run, see . /// A task representing the asynchronous operation. - private async Task RunTask(CancellationToken ct, long generation) + private async Task RunTask() { ResetAllItems(); if (ScreenshotData.IsEnabled) { - // Wait like a real check, so the loading animation is visible - await Task.Delay(GlobalStaticConfiguration.ApplicationUIRefreshInterval, ct); - - SetScreenshotData(generation); + SetScreenshotData(); return; } @@ -232,19 +195,16 @@ private async Task RunTask(CancellationToken ct, long generation) await Task.WhenAll(localIPv4Task, localIPv6Task); - if (ct.IsCancellationRequested) - ct.ThrowIfCancellationRequested(); - var localIPv4 = localIPv4Task.Result; var localIPv6 = localIPv6Task.Result; - SetAddressResult(ComputerIPv4, localIPv4, generation); - SetAddressResult(ComputerIPv6, localIPv6, generation); + SetAddressResult(ComputerIPv4, localIPv4); + SetAddressResult(ComputerIPv6, localIPv6); await Task.WhenAll( - CheckConnectionComputerDnsAsync(ct, generation), - CheckConnectionRouterAsync(localIPv4, localIPv6, ct, generation), - CheckConnectionInternetAsync(ct, generation) + CheckConnectionComputerDnsAsync(), + CheckConnectionRouterAsync(localIPv4, localIPv6), + CheckConnectionInternetAsync() ); } @@ -272,14 +232,10 @@ private void ResetAllItems() } /// - /// Sets the sample data of instead of the real (personal) addresses, unless a newer - /// check has started in the meantime. + /// Sets the sample data of instead of the real (personal) addresses. /// - private void SetScreenshotData(long generation) + private void SetScreenshotData() { - if (generation != _generation) - return; - ComputerIPv4.Complete(ScreenshotData.ComputerIPv4, ConnectionState.OK); ComputerIPv6.Complete(ScreenshotData.ComputerIPv6, ConnectionState.OK); ComputerDNS.Complete(ScreenshotData.ComputerDNS, ConnectionState.OK); @@ -369,27 +325,22 @@ private static async Task DetectLocalIPv6Async() } /// - /// Applies a detected address to a , unless a newer check has - /// started in the meantime. + /// Applies a detected address to a . /// - private void SetAddressResult(ConnectionCheckItem item, IPAddress detected, long generation) + private static void SetAddressResult(ConnectionCheckItem item, IPAddress detected) { - if (generation != _generation) - return; - item.Complete(detected?.ToString() ?? "-/-", detected != null ? ConnectionState.OK : ConnectionState.Critical); } /// - /// Resolves the DNS (PTR) name for an address item, trying IPv4 first and falling back to IPv6, - /// unless a newer check has started in the meantime. + /// Resolves the DNS (PTR) name for an address item, trying IPv4 first and falling back to IPv6. /// /// /// A PTR lookup that completes without a server error but simply has no record (e.g. most home /// routers and many ISPs don't configure reverse DNS) is reported as /// rather than - it's not a sign of a broken DNS setup. /// - private async Task ResolveDnsAsync(ConnectionCheckItem dnsItem, ConnectionCheckItem addressIPv4, ConnectionCheckItem addressIPv6, long generation, string context) + private async Task ResolveDnsAsync(ConnectionCheckItem dnsItem, ConnectionCheckItem addressIPv4, ConnectionCheckItem addressIPv6, string context) { DNSClientResultString ipv4Result = null; DNSClientResultString ipv6Result = null; @@ -406,9 +357,6 @@ private async Task ResolveDnsAsync(ConnectionCheckItem dnsItem, ConnectionCheckI ipv6Result = await DNSClient.GetInstance().ResolvePtrAsync(IPAddress.Parse(addressIPv6.Value)); } - if (generation != _generation) - return; - // Prefer a successful resolution from either family. If neither succeeded, a clean // "not found" from either family still wins over a hard failure from the other - e.g. // IPv4 has no PTR (NXDOMAIN) while IPv6 times out should show as "no record", not as a @@ -436,14 +384,14 @@ private async Task ResolveDnsAsync(ConnectionCheckItem dnsItem, ConnectionCheckI /// /// Resolves the computer's DNS (PTR) name. /// - private Task CheckConnectionComputerDnsAsync(CancellationToken ct, long generation) + private Task CheckConnectionComputerDnsAsync() { return Task.Run(async () => { Log.Debug($"{nameof(CheckConnectionComputerDnsAsync)} - Checking computer DNS..."); - await ResolveDnsAsync(ComputerDNS, ComputerIPv4, ComputerIPv6, generation, nameof(CheckConnectionComputerDnsAsync)); + await ResolveDnsAsync(ComputerDNS, ComputerIPv4, ComputerIPv6, nameof(CheckConnectionComputerDnsAsync)); Log.Debug($"{nameof(CheckConnectionComputerDnsAsync)} - Computer DNS check completed."); - }, ct); + }); } /// @@ -451,10 +399,8 @@ private Task CheckConnectionComputerDnsAsync(CancellationToken ct, long generati /// /// The already-detected local IPv4 address, or null. /// The already-detected local IPv6 address, or null. - /// The cancellation token. - /// The id of this check run, see . /// A task representing the asynchronous operation. - private Task CheckConnectionRouterAsync(IPAddress localIPv4, IPAddress localIPv6, CancellationToken ct, long generation) + private Task CheckConnectionRouterAsync(IPAddress localIPv4, IPAddress localIPv6) { return Task.Run(async () => { @@ -467,10 +413,7 @@ private Task CheckConnectionRouterAsync(IPAddress localIPv4, IPAddress localIPv6 ? await NetworkInterface.DetectGatewayFromLocalIPAddressAsync(localIPv4) : null; - SetAddressResult(RouterIPv4, routerIPv4, generation); - - if (ct.IsCancellationRequested) - ct.ThrowIfCancellationRequested(); + SetAddressResult(RouterIPv4, routerIPv4); // Detect router IPv6 gateway Log.Debug($"{nameof(CheckConnectionRouterAsync)} - Detecting router IPv6 address..."); @@ -479,25 +422,20 @@ private Task CheckConnectionRouterAsync(IPAddress localIPv4, IPAddress localIPv6 ? await NetworkInterface.DetectGatewayFromLocalIPAddressAsync(localIPv6) : null; - SetAddressResult(RouterIPv6, routerIPv6, generation); - - if (ct.IsCancellationRequested) - ct.ThrowIfCancellationRequested(); + SetAddressResult(RouterIPv6, routerIPv6); // Resolve router DNS - await ResolveDnsAsync(RouterDNS, RouterIPv4, RouterIPv6, generation, nameof(CheckConnectionRouterAsync)); + await ResolveDnsAsync(RouterDNS, RouterIPv4, RouterIPv6, nameof(CheckConnectionRouterAsync)); Log.Debug($"{nameof(CheckConnectionRouterAsync)} - Router connection check completed."); - }, ct); + }); } /// /// Checks the internet connection asynchronously. /// - /// The cancellation token. - /// The id of this check run, see . /// A task representing the asynchronous operation. - private Task CheckConnectionInternetAsync(CancellationToken ct, long generation) + private Task CheckConnectionInternetAsync() { return Task.Run(async () => { @@ -518,13 +456,10 @@ private Task CheckConnectionInternetAsync(CancellationToken ct, long generation) { Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Checking public IPv4 address from: " + publicIPv4AddressAPI); - var httpResponse = await PublicIPHttpClient.GetAsync(publicIPv4AddressAPI, ct); - var result = await httpResponse.Content.ReadAsStringAsync(ct); + var httpResponse = await PublicIPHttpClient.GetAsync(publicIPv4AddressAPI); + var result = await httpResponse.Content.ReadAsStringAsync(); var match = RegexHelper.IPv4AddressExtractRegex().Match(result); - if (generation != _generation) - return; - if (match.Success) { Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv4 address detected: " + match.Value); @@ -536,17 +471,13 @@ private Task CheckConnectionInternetAsync(CancellationToken ct, long generation) InternetIPv4.Complete("-/-", ConnectionState.Critical); } } - catch (Exception ex) when (ex is not OperationCanceledException) + catch (Exception ex) { Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv4 address not detected due to exception: " + ex.Message); - if (generation == _generation) - InternetIPv4.Complete("-/-", ConnectionState.Critical); + InternetIPv4.Complete("-/-", ConnectionState.Critical); } - if (ct.IsCancellationRequested) - ct.ThrowIfCancellationRequested(); - // Detect public IPv6 and if it is reachable Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Detecting public IPv6 address..."); @@ -558,13 +489,10 @@ private Task CheckConnectionInternetAsync(CancellationToken ct, long generation) { Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Checking public IPv6 address from: " + publicIPv6AddressAPI); - var httpResponse = await PublicIPHttpClient.GetAsync(publicIPv6AddressAPI, ct); - var result = await httpResponse.Content.ReadAsStringAsync(ct); + var httpResponse = await PublicIPHttpClient.GetAsync(publicIPv6AddressAPI); + var result = await httpResponse.Content.ReadAsStringAsync(); var match = Regex.Match(result, RegexHelper.IPv6AddressRegex); - if (generation != _generation) - return; - if (match.Success) { Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv6 address detected: " + match.Value); @@ -576,22 +504,18 @@ private Task CheckConnectionInternetAsync(CancellationToken ct, long generation) InternetIPv6.Complete("-/-", ConnectionState.Critical); } } - catch (Exception ex) when (ex is not OperationCanceledException) + catch (Exception ex) { Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv6 address not detected due to exception: " + ex.Message); - if (generation == _generation) - InternetIPv6.Complete("-/-", ConnectionState.Critical); + InternetIPv6.Complete("-/-", ConnectionState.Critical); } - if (ct.IsCancellationRequested) - ct.ThrowIfCancellationRequested(); - // Resolve internet DNS - await ResolveDnsAsync(InternetDNS, InternetIPv4, InternetIPv6, generation, nameof(CheckConnectionInternetAsync)); + await ResolveDnsAsync(InternetDNS, InternetIPv4, InternetIPv6, nameof(CheckConnectionInternetAsync)); Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Internet connection check completed."); - }, ct); + }); } #endregion diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index f05bc2902a..09022a0fff 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -121,6 +121,10 @@ Release date: **xx.xx.2026** - Fixed the license of ControlzEx in the library list: it showed the license text and link of Dragablz. [#3717](https://github.com/BornToBeRoot/NETworkManager/pull/3717) - Updated the license of MahApps.Metro in the library list (copyright: .NET Foundation and Contributors). [#3717](https://github.com/BornToBeRoot/NETworkManager/pull/3717) +**Dashboard** + +- Fixed the network connection check getting stuck (all values loading until the next refresh) when the refresh was used several times while a check was running. A refresh during a check now repeats the check once it has finished. [#PR](PRLINK) + ## Dependencies, Refactoring & Documentation - Code cleanup & refactoring From 1be2df8732806d013ccd7245d34c5b7c013bc361 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:13:01 +0100 Subject: [PATCH 02/56] Fix: Dashboard: Widget ignores changed Check public IP address setting (B2) Co-Authored-By: Claude Opus 5.5 --- .../ViewModels/NetworkConnectionWidgetViewModel.cs | 11 +++-------- .../Views/NetworkConnectionWidgetView.xaml | 5 +++-- Website/docs/changelog/next-release.md | 1 + 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index f6ace14900..001e3c21f7 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -87,11 +87,6 @@ public class NetworkConnectionWidgetViewModel : ViewModelBase #endregion - /// - /// Gets a value indicating whether checking the public IP address is enabled. - /// - public bool CheckPublicIPAddressEnabled => SettingsManager.Current.Dashboard_CheckPublicIPAddress; - /// /// Gets or sets a value indicating whether a check is currently running. /// @@ -223,7 +218,7 @@ private void ResetAllItems() RouterIPv6.Reset(); RouterDNS.Reset(); - if (!CheckPublicIPAddressEnabled) + if (!SettingsManager.Current.Dashboard_CheckPublicIPAddress) return; InternetIPv4.Reset(); @@ -244,7 +239,7 @@ private void SetScreenshotData() RouterIPv6.Complete(ScreenshotData.RouterIPv6, ConnectionState.OK); RouterDNS.Complete(ScreenshotData.RouterDNS, ConnectionState.OK); - if (!CheckPublicIPAddressEnabled) + if (!SettingsManager.Current.Dashboard_CheckPublicIPAddress) return; InternetIPv4.Complete(ScreenshotData.InternetIPv4, ConnectionState.OK); @@ -440,7 +435,7 @@ private Task CheckConnectionInternetAsync() return Task.Run(async () => { // If public IP address check is disabled - if (!CheckPublicIPAddressEnabled) + if (!SettingsManager.Current.Dashboard_CheckPublicIPAddress) return; Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Checking internet connection..."); diff --git a/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml b/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml index 433800a607..c96ddd6586 100644 --- a/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml +++ b/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml @@ -8,6 +8,7 @@ xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:viewModels="clr-namespace:NETworkManager.ViewModels" + xmlns:settings="clr-namespace:NETworkManager.Settings;assembly=NETworkManager.Settings" xmlns:wpfHelpers="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF" mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:NetworkConnectionWidgetViewModel}"> @@ -207,7 +208,7 @@ + Visibility="{Binding Source={x:Static settings:SettingsManager.Current}, Path=Dashboard_CheckPublicIPAddress, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}"> @@ -246,7 +247,7 @@ diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 09022a0fff..9ba592c524 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -124,6 +124,7 @@ Release date: **xx.xx.2026** **Dashboard** - Fixed the network connection check getting stuck (all values loading until the next refresh) when the refresh was used several times while a check was running. A refresh during a check now repeats the check once it has finished. [#PR](PRLINK) +- Fixed the network connection widget (dashboard and status window) not updating when **Check public IP address** was changed in the settings until the application was restarted: an old public IP address could be shown as current. [#PR](PRLINK) ## Dependencies, Refactoring & Documentation From 5535b58518dfb279206a727f8536fbcc0d16cc67 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:14:00 +0100 Subject: [PATCH 03/56] Fix: Status window: Handle network changes once the network has settled (S1) Trailing debounce with a DispatcherTimer on the UI thread instead of an unsynchronized flag in an async void handler on a thread-pool thread (an exception left the flag set or ended the process). Co-Authored-By: Claude Opus 5.5 --- Source/NETworkManager/MainWindow.xaml.cs | 52 ++++++++++++++++-------- Website/docs/changelog/next-release.md | 4 ++ 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/Source/NETworkManager/MainWindow.xaml.cs b/Source/NETworkManager/MainWindow.xaml.cs index da3f478990..0397a570b7 100644 --- a/Source/NETworkManager/MainWindow.xaml.cs +++ b/Source/NETworkManager/MainWindow.xaml.cs @@ -123,11 +123,16 @@ private void OnPropertyChanged([CallerMemberName] string propertyName = null) /// private readonly DispatcherTimer _configureDNSServerDispatcherTimer = new(); + /// + /// Timer to handle a network change once the network has settled: Windows raises several events per change (e.g. + /// link up, then the DHCP address), every event restarts the timer. + /// + private readonly DispatcherTimer _networkChangeDispatcherTimer = new(); + private readonly bool _isLoading; private bool _isProfileFilesLoading; private bool _isProfileFileUpdating; private bool _isApplicationViewLoading; - private bool _isNetworkChanging; private bool _isInTray; private bool _isClosing; @@ -566,6 +571,10 @@ private void Load() _statusWindow = new StatusWindow(this); // Detect network changes... + _networkChangeDispatcherTimer.Interval = + TimeSpan.FromMilliseconds(GlobalStaticConfiguration.NetworkChangeDetectionDelay); + _networkChangeDispatcherTimer.Tick += NetworkChangeDispatcherTimer_Tick; + NetworkChange.NetworkAvailabilityChanged += (_, _) => OnNetworkHasChanged(); NetworkChange.NetworkAddressChanged += (_, _) => OnNetworkHasChanged(); @@ -1852,33 +1861,40 @@ private void OpenStatusWindow(bool enableCloseTimer = false) _statusWindow.ShowWindow(enableCloseTimer); } - private async void OnNetworkHasChanged() + /// + /// Called by the events (thread pool, several times per change). (Re)starts the + /// timer on the UI thread, so the change is handled once, when the network has settled. + /// + private void OnNetworkHasChanged() { - if (_isNetworkChanging) - return; - - _isNetworkChanging = true; + Dispatcher.InvokeAsync(() => + { + _networkChangeDispatcherTimer.Stop(); + _networkChangeDispatcherTimer.Start(); + }); + } - // Wait, because the event may be triggered several times. - await Task.Delay(GlobalStaticConfiguration.NetworkChangeDetectionDelay); + private async void NetworkChangeDispatcherTimer_Tick(object sender, EventArgs e) + { + _networkChangeDispatcherTimer.Stop(); Log.Info("Network availability or address has changed!"); // Reconfigure the DNS client if network changed - re-detects the Windows default DNS servers // and, if enabled, the auto-detected DNS suffix (both of which can differ on the new network). - Log.Info("Update DNS server configuration..."); - ConfigureDNSServer(); - - // Show status window on network change - if (SettingsManager.Current.Status_ShowWindowOnNetworkChange) + try { - await Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate - { - OpenStatusWindow(true); - })); + Log.Info("Update DNS server configuration..."); + await Task.Run(ConfigureDNSServer); + } + catch (Exception ex) + { + Log.Error("Could not update the DNS server configuration after the network has changed.", ex); } - _isNetworkChanging = false; + // Show status window on network change + if (SettingsManager.Current.Status_ShowWindowOnNetworkChange) + OpenStatusWindow(true); } #endregion diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 9ba592c524..6183bea493 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -126,6 +126,10 @@ Release date: **xx.xx.2026** - Fixed the network connection check getting stuck (all values loading until the next refresh) when the refresh was used several times while a check was running. A refresh during a check now repeats the check once it has finished. [#PR](PRLINK) - Fixed the network connection widget (dashboard and status window) not updating when **Check public IP address** was changed in the settings until the application was restarted: an old public IP address could be shown as current. [#PR](PRLINK) +**Status window** + +- The status window now opens after a network change once the network has settled (5 seconds without further changes, e.g. after the DHCP address was assigned) instead of 5 seconds after the first change, so it no longer shows an intermediate state. An error while updating the DNS configuration after a network change no longer stops the detection of further network changes. [#PR](PRLINK) + ## Dependencies, Refactoring & Documentation - Code cleanup & refactoring From 73c97fa98fc129c4292ea62738a124637a55a69d Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:15:01 +0100 Subject: [PATCH 04/56] Fix: Dashboard: Check again on network change, at most every 60 s on switch (B7, P2) The main window notifies the dashboard after a network change: checked right away if visible, otherwise marked outdated. Switching back checks only if outdated (network / dashboard setting changed) or the last check is older than Dashboard_RecheckInterval (60 s). Same mechanism, one commit. Co-Authored-By: Claude Opus 5.5 --- .../GlobalStaticConfiguration.cs | 6 ++ Source/NETworkManager/MainWindow.xaml.cs | 3 + .../Views/DashboardView.xaml.cs | 61 +++++++++++++++++-- Website/docs/application/dashboard.md | 2 +- Website/docs/changelog/next-release.md | 5 ++ 5 files changed, 71 insertions(+), 6 deletions(-) diff --git a/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs b/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs index 869ca70bd8..e825803b83 100644 --- a/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs +++ b/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs @@ -140,6 +140,12 @@ public static class GlobalStaticConfiguration public static bool Dashboard_CheckIPApiIPGeolocation => false; public static bool Dashboard_CheckIPApiDNSResolver => false; + /// + /// Minimum time between two network connection checks when switching back to the dashboard (the public IP address + /// may have changed, but no requests on every switch). A refresh and a network change always check. + /// + public static TimeSpan Dashboard_RecheckInterval => TimeSpan.FromSeconds(60); + // Application: Network Interface public static ExportFileType NetworkInterface_ExportFileType => ExportFileType.Csv; public static int NetworkInterface_BandwidthChartTime => 60; diff --git a/Source/NETworkManager/MainWindow.xaml.cs b/Source/NETworkManager/MainWindow.xaml.cs index 0397a570b7..18dd73abf1 100644 --- a/Source/NETworkManager/MainWindow.xaml.cs +++ b/Source/NETworkManager/MainWindow.xaml.cs @@ -1892,6 +1892,9 @@ private async void NetworkChangeDispatcherTimer_Tick(object sender, EventArgs e) Log.Error("Could not update the DNS server configuration after the network has changed.", ex); } + // Check the network connection on the dashboard again + _dashboardView?.OnNetworkChanged(); + // Show status window on network change if (SettingsManager.Current.Status_ShowWindowOnNetworkChange) OpenStatusWindow(true); diff --git a/Source/NETworkManager/Views/DashboardView.xaml.cs b/Source/NETworkManager/Views/DashboardView.xaml.cs index 60a7f1611f..116e92de9a 100644 --- a/Source/NETworkManager/Views/DashboardView.xaml.cs +++ b/Source/NETworkManager/Views/DashboardView.xaml.cs @@ -1,4 +1,7 @@ -using NETworkManager.ViewModels; +using System; +using System.ComponentModel; +using NETworkManager.Settings; +using NETworkManager.ViewModels; namespace NETworkManager.Views; @@ -11,6 +14,20 @@ public partial class DashboardView private readonly IPApiDNSResolverWidgetView _ipApiDNSResolverWidgetView = new(); private readonly SpeedTestWidgetView _speedTestWidgetView = new(); + /// + /// The dashboard is the selected application (see / ). + /// + private bool _isViewVisible = true; + + /// + /// The network or a dashboard setting changed while the dashboard was hidden: check again when it is shown. + /// + private bool _isOutdated; + + /// + /// Start of the last network connection check, see . + /// + private DateTime _lastCheck; public DashboardView() { @@ -23,20 +40,54 @@ public DashboardView() ContentControlIPApiDNSResolver.Content = _ipApiDNSResolverWidgetView; ContentControlSpeedTest.Content = _speedTestWidgetView; + // The settings are changed while the dashboard is hidden (settings view) - check again when it is shown + SettingsManager.Current.PropertyChanged += SettingsManager_PropertyChanged; + // Check network connection on first open. Later re-opens are covered by OnViewVisible(). - _networkConnectionWidgetView.Check(); + CheckNetworkConnection(); } public void OnViewVisible() { + _isViewVisible = true; + _viewModel.OnViewVisible(); - // Check network connection - _networkConnectionWidgetView.Check(); + // Check the network connection again if something changed, or if the last check is older than the recheck + // interval (e.g. the public IP address may have changed) - not on every switch between the applications + if (_isOutdated || DateTime.Now - _lastCheck >= GlobalStaticConfiguration.Dashboard_RecheckInterval) + CheckNetworkConnection(); } public void OnViewHide() { + _isViewVisible = false; + _viewModel.OnViewHide(); } -} + + /// + /// Called by the main window when the network has changed (addresses, adapter connected or disconnected). + /// + public void OnNetworkChanged() + { + if (_isViewVisible) + CheckNetworkConnection(); + else + _isOutdated = true; + } + + private void CheckNetworkConnection() + { + _isOutdated = false; + _lastCheck = DateTime.Now; + + _networkConnectionWidgetView.Check(); + } + + private void SettingsManager_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName?.StartsWith("Dashboard_", StringComparison.Ordinal) == true) + _isOutdated = true; + } +} \ No newline at end of file diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index 919e59143f..cfc9ffbb67 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -6,7 +6,7 @@ keywords: [NETworkManager, dashboard, network status, network connection, networ # Dashboard -The **Dashboard** shows the status of your computer's current network connection to provide a quick overview of the most important information. Whenever the local network adapter changes state (e.g. an Ethernet cable is plugged in, Wi-Fi or VPN connects), the dashboard checks connectivity to the router and the internet. +The **Dashboard** shows the status of your computer's current network connection to provide a quick overview of the most important information. Whenever the local network adapter changes state (e.g. an Ethernet cable is plugged in, Wi-Fi or VPN connects), the dashboard checks connectivity to the router and the internet. When you switch back to the dashboard, the network connection is only checked again if the last check is at least 60 seconds old (e.g. the public IP address may have changed) or the network or the dashboard settings have changed in the meantime, so switching between the tools doesn't send a request each time. **F5** or the refresh button always checks again. ![Dashboard](../img/dashboard.png) diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 6183bea493..6c0ab32cbe 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -49,6 +49,10 @@ Release date: **xx.xx.2026** - Renamed "Discovery Protocol" to "LLDP / CDP Capture", so it is clear what the tool does (and it is not confused with mDNS Discovery). The run command is now `lldpcdpcapture` with the aliases `lldp` and `cdp`, the documentation moved to [LLDP / CDP Capture](../application/lldp-cdp-capture.md). The selected protocol and duration are reset to the defaults. [#3721](https://github.com/BornToBeRoot/NETworkManager/issues/3721) +**Dashboard** + +- Switching back to the dashboard checks the network connection only if the last check is at least 60 seconds old (or the network / the dashboard settings changed), instead of on every switch between the tools. **F5** and the refresh button always check. [#PR](PRLINK) + ## Bug Fixes **Tabs** @@ -125,6 +129,7 @@ Release date: **xx.xx.2026** - Fixed the network connection check getting stuck (all values loading until the next refresh) when the refresh was used several times while a check was running. A refresh during a check now repeats the check once it has finished. [#PR](PRLINK) - Fixed the network connection widget (dashboard and status window) not updating when **Check public IP address** was changed in the settings until the application was restarted: an old public IP address could be shown as current. [#PR](PRLINK) +- Fixed the network connection not being checked again when the network changed while the dashboard was open (e.g. a cable unplugged or a VPN connected), although the documentation says so. If the dashboard is not open, it is checked when it is opened again. [#PR](PRLINK) **Status window** From b9f0183f77cd1eff6db73c53215c549e3ac03a72 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:16:09 +0100 Subject: [PATCH 05/56] Fix: Status window: Don't steal the focus on a network change, close timer (S2, S3) S2: ShowActivated = false when opened on a network change; clicking into the window (Activated) stops the close timer. S3: HideWindow() stops the 33 ms close timer (kept ticking after the window was hidden); the expired timer only hides the window if it is still the same run (opened again within the 250 ms delay). Co-Authored-By: Claude Opus 5.5 --- Source/NETworkManager/StatusWindow.xaml | 1 + Source/NETworkManager/StatusWindow.xaml.cs | 62 ++++++++++++++++++---- Website/docs/changelog/next-release.md | 2 + 3 files changed, 56 insertions(+), 9 deletions(-) diff --git a/Source/NETworkManager/StatusWindow.xaml b/Source/NETworkManager/StatusWindow.xaml index d32b907e58..778216e572 100644 --- a/Source/NETworkManager/StatusWindow.xaml +++ b/Source/NETworkManager/StatusWindow.xaml @@ -11,6 +11,7 @@ mc:Ignorable="d" d:DataContext="{d:DesignInstance networkManager:StatusWindow}" TitleAlignment="Left" Style="{DynamicResource ResourceKey=FrameWindow}" + Activated="MetroWindow_Activated" Deactivated="MetroWindow_Deactivated" Topmost="True" ShowInTaskbar="False" diff --git a/Source/NETworkManager/StatusWindow.xaml.cs b/Source/NETworkManager/StatusWindow.xaml.cs index 8da7006ba6..c842c7976a 100644 --- a/Source/NETworkManager/StatusWindow.xaml.cs +++ b/Source/NETworkManager/StatusWindow.xaml.cs @@ -54,6 +54,12 @@ private void OnPropertyChanged([CallerMemberName] string propertyName = null) private readonly DispatcherTimer _dispatcherTimerClose = new(DispatcherPriority.Render); private readonly Stopwatch _stopwatch = new(); + /// + /// Incremented whenever the close timer is started or stopped. The expired timer only hides the window if it is + /// still the same run (the user may have opened the window again while the timer waited before hiding it). + /// + private int _closeTimerRun; + private readonly MainWindow _mainWindow; private readonly NetworkConnectionWidgetView _networkConnectionView; @@ -106,7 +112,7 @@ public double Time private void ShowMainWindowAction() { - Hide(); + HideWindow(); if (_mainWindow.ShowWindowCommand.CanExecute(null)) _mainWindow.ShowWindowCommand.Execute(null); @@ -116,7 +122,7 @@ private void ShowMainWindowAction() private void CloseAction() { - Hide(); + HideWindow(); } #endregion @@ -138,6 +144,10 @@ public void ShowWindow(bool enableCloseTimer = false) // height is only known after layout, so this is refined again in SizeChanged. UpdatePosition(); + // Opened on a network change: don't take the focus from the application the user is working in (the window + // closes itself, see the close timer). Clicking into it stops the close timer (Activated). + ShowActivated = !enableCloseTimer; + // Show the window Show(); @@ -152,9 +162,7 @@ public void ShowWindow(bool enableCloseTimer = false) } // Opened by the user, cancel a running close timer (e.g. if the window was opened on a network change) - _dispatcherTimerClose.Stop(); - _stopwatch.Stop(); - ShowTime = false; + StopCloseTimer(); // Focus the window Activate(); @@ -179,6 +187,8 @@ private void UpdatePosition() private void SetupCloseTimer() { + _closeTimerRun++; + TimeMax = SettingsManager.Current.Status_WindowCloseTime; Time = TimeMax; @@ -187,20 +197,50 @@ private void SetupCloseTimer() _dispatcherTimerClose.Start(); } + /// + /// Stops the close timer (e.g. the window is opened by the user or hidden). A pending close of the expired timer + /// is canceled, see . + /// + private void StopCloseTimer() + { + _closeTimerRun++; + + _dispatcherTimerClose.Stop(); + _stopwatch.Stop(); + ShowTime = false; + } + + /// + /// Hides the window and stops the close timer, so it doesn't keep running in the background. + /// + private void HideWindow() + { + StopCloseTimer(); + + Hide(); + } + #endregion #region Events + private void MetroWindow_Activated(object sender, EventArgs e) + { + // The user clicked into the window that was opened on a network change: keep it open (like opened by the user) + if (_dispatcherTimerClose.IsEnabled) + StopCloseTimer(); + } + private void MetroWindow_Deactivated(object sender, EventArgs e) { - Hide(); + HideWindow(); } private void MetroWindow_Closing(object sender, CancelEventArgs e) { e.Cancel = true; - Hide(); + HideWindow(); } private async void DispatcherTimerTime_Tick(object sender, EventArgs e) @@ -216,11 +256,15 @@ private async void DispatcherTimerTime_Tick(object sender, EventArgs e) _dispatcherTimerClose.Stop(); _stopwatch.Stop(); + var run = _closeTimerRun; + await Task.Delay(250); - ShowTime = false; + // Opened again (by the user or another network change) in the meantime + if (run != _closeTimerRun) + return; - Hide(); + HideWindow(); } #endregion diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 6c0ab32cbe..1f67f103a2 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -134,6 +134,8 @@ Release date: **xx.xx.2026** **Status window** - The status window now opens after a network change once the network has settled (5 seconds without further changes, e.g. after the DHCP address was assigned) instead of 5 seconds after the first change, so it no longer shows an intermediate state. An error while updating the DNS configuration after a network change no longer stops the detection of further network changes. [#PR](PRLINK) +- The status window that opens on a network change no longer takes the keyboard focus from the application you are working in. Clicking into it keeps it open (the countdown stops). [#PR](PRLINK) +- Fixed the status window being hidden right after it was opened from the tray icon when the countdown of a previous network change had just ended. [#PR](PRLINK) ## Dependencies, Refactoring & Documentation From 5ede5edfe0ea91570cacc86c4b1cbaa700daf29b Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:16:13 +0100 Subject: [PATCH 06/56] Fix: Status window: Cut off on the left on small screens (S4) Co-Authored-By: Claude Opus 5.5 --- Source/NETworkManager/StatusWindow.xaml.cs | 10 ++++++++-- Website/docs/changelog/next-release.md | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/NETworkManager/StatusWindow.xaml.cs b/Source/NETworkManager/StatusWindow.xaml.cs index c842c7976a..924fd55b27 100644 --- a/Source/NETworkManager/StatusWindow.xaml.cs +++ b/Source/NETworkManager/StatusWindow.xaml.cs @@ -180,9 +180,15 @@ private void UpdatePosition() return; var scaleFactor = System.Windows.Media.VisualTreeHelper.GetDpi(this).DpiScaleX; + var workingArea = Screen.PrimaryScreen.WorkingArea; - Left = Screen.PrimaryScreen.WorkingArea.Right / scaleFactor - Width - 10; - Top = Screen.PrimaryScreen.WorkingArea.Bottom / scaleFactor - ActualHeight - 10; + // Not wider than the working area (e.g. 1280 x 720 with 150 % scaling is 853 px wide), otherwise the window + // would start outside the screen on the left + MaxWidth = Math.Max(0, workingArea.Width / scaleFactor - 20); + + Left = Math.Max(workingArea.Left / scaleFactor + 10, + workingArea.Right / scaleFactor - Math.Min(Width, MaxWidth) - 10); + Top = workingArea.Bottom / scaleFactor - ActualHeight - 10; } private void SetupCloseTimer() diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 1f67f103a2..152ff51f6f 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -136,6 +136,7 @@ Release date: **xx.xx.2026** - The status window now opens after a network change once the network has settled (5 seconds without further changes, e.g. after the DHCP address was assigned) instead of 5 seconds after the first change, so it no longer shows an intermediate state. An error while updating the DNS configuration after a network change no longer stops the detection of further network changes. [#PR](PRLINK) - The status window that opens on a network change no longer takes the keyboard focus from the application you are working in. Clicking into it keeps it open (the countdown stops). [#PR](PRLINK) - Fixed the status window being hidden right after it was opened from the tray icon when the countdown of a previous network change had just ended. [#PR](PRLINK) +- Fixed the status window being cut off on the left on small screens (e.g. 1280 x 720 with 150 % scaling). It is no longer wider than the screen. [#PR](PRLINK) ## Dependencies, Refactoring & Documentation From 95fcd5a4aee42d48656064c21ccf1643fc7221dd Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:18:49 +0100 Subject: [PATCH 07/56] Fix: Dashboard: Detect local IP / gateway without PowerShell, also on VPN adapters (P1, B6) GetNetworkInterfaces() (PowerShell Get-NetConnectionProfile + registry) was called up to 4 times per check. The fallback detection and the gateway lookup now only read System.Net.NetworkInformation; the gateway lookup searches all adapters (Ppp / Tunnel too) and skips 0.0.0.0 / ::. Selection logic in SelectLocalIPAddress / SelectGateway + tests (T3). Co-Authored-By: Claude Opus 5.5 --- .../Network/NetworkInterface.cs | 166 ++++++++++-------- .../Network/NetworkInterfaceDetectionTests.cs | 119 +++++++++++++ Website/docs/changelog/next-release.md | 2 + 3 files changed, 210 insertions(+), 77 deletions(-) create mode 100644 Source/NETworkManager.Tests/Network/NetworkInterfaceDetectionTests.cs diff --git a/Source/NETworkManager.Models/Network/NetworkInterface.cs b/Source/NETworkManager.Models/Network/NetworkInterface.cs index 2aced18d56..ed8c09d3b7 100644 --- a/Source/NETworkManager.Models/Network/NetworkInterface.cs +++ b/Source/NETworkManager.Models/Network/NetworkInterface.cs @@ -109,19 +109,7 @@ public static List GetNetworkInterfaces() foreach (var networkInterface in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()) { - // NetworkInterfaceType 53 is proprietary virtual/internal interface - // https://docs.microsoft.com/en-us/windows-hardware/drivers/network/ndis-interface-types - if (networkInterface.NetworkInterfaceType != NetworkInterfaceType.Ethernet && - networkInterface.NetworkInterfaceType != NetworkInterfaceType.Wireless80211 && - (int)networkInterface.NetworkInterfaceType != 53) - continue; - - // Filter out virtual/filter adapters introduced in .NET 9/10 - // Check if the adapter name or description contains any filtered pattern - // See: https://github.com/dotnet/runtime/issues/122751 - if (NetworkInterfaceFilteredPatterns.Any(pattern => - networkInterface.Name.Contains(pattern) || - networkInterface.Description.Contains(pattern))) + if (!IsSupportedNetworkInterface(networkInterface)) continue; var listIPv4Address = new List>(); @@ -233,6 +221,29 @@ public static List GetNetworkInterfaces() return listNetworkInterfaceInfo; } + /// + /// Network interfaces shown and used by the application: Ethernet, Wireless80211 and proprietary virtual/internal + /// interfaces, without the virtual/filter adapters listed in . + /// + /// Network interface of the .NET API. + /// if the network interface is supported. + private static bool IsSupportedNetworkInterface(System.Net.NetworkInformation.NetworkInterface networkInterface) + { + // NetworkInterfaceType 53 is proprietary virtual/internal interface + // https://docs.microsoft.com/en-us/windows-hardware/drivers/network/ndis-interface-types + if (networkInterface.NetworkInterfaceType != NetworkInterfaceType.Ethernet && + networkInterface.NetworkInterfaceType != NetworkInterfaceType.Wireless80211 && + (int)networkInterface.NetworkInterfaceType != 53) + return false; + + // Filter out virtual/filter adapters introduced in .NET 9/10 + // Check if the adapter name or description contains any filtered pattern + // See: https://github.com/dotnet/runtime/issues/122751 + return !NetworkInterfaceFilteredPatterns.Any(pattern => + networkInterface.Name.Contains(pattern) || + networkInterface.Description.Contains(pattern)); + } + /// /// Finds a network interface by its ID (GUID, unique per computer; the name is not). /// @@ -363,69 +374,55 @@ public static Task DetectLocalIPAddressFromNetworkInterfaceAsync(Addr /// /// Detects and returns the first local IP address assigned to an operational network interface that matches the - /// specified address family. + /// specified address family, see . /// - /// For IPv4, the method prefers non-link-local addresses but will return a link-local address if - /// no other is available. For IPv6, the method returns the first global or unique local address if present; - /// otherwise, it returns a link-local address if available. The returned address is selected from operational - /// network interfaces only. + /// Only reads the addresses (no PowerShell / registry like ), the + /// network interfaces are filtered the same way. /// The address family to search for. Specify for IPv4 addresses or for IPv6 addresses. /// An representing the first detected local IP address for the specified address family, or /// if no suitable address is found. public static IPAddress DetectLocalIPAddressFromNetworkInterface(AddressFamily addressFamily) { - // Filter operational network interfaces - var networkInterfaces = GetNetworkInterfaces() - .Where(x => x.IsOperational) - .ToList(); - - var candidates = new List(); + var addresses = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces() + .Where(x => x.OperationalStatus == OperationalStatus.Up && IsSupportedNetworkInterface(x)) + .Select(x => x.GetIPProperties().UnicastAddresses.Select(y => y.Address).ToArray()); - switch (addressFamily) - { - // IPv4 - case AddressFamily.InterNetwork: - { - foreach (var networkInterface in networkInterfaces) - { - foreach (var ipAddress in networkInterface.IPv4Address) - candidates.Add(ipAddress.Item1); - } - - // Prefer non-link-local addresses - var nonLinkLocal = candidates.FirstOrDefault(x => - { - var bytes = x.GetAddressBytes(); - - return !(bytes[0] == 169 && bytes[1] == 254); - }); + return SelectLocalIPAddress(addresses, addressFamily); + } - // Return first non-link-local or first candidate if none found (might be null - no addresses at all) - return nonLinkLocal ?? candidates.FirstOrDefault(); - } - // IPv6 - case AddressFamily.InterNetworkV6: - { - // First try to get global or unique local addresses - foreach (var networkInterface in networkInterfaces) - candidates.AddRange(networkInterface.IPv6Address); + /// + /// Selects the local IP address of the address family from the addresses of the network interfaces (in their + /// order). For IPv4, the first address that is not link-local (169.254.x.x, no DHCP server) is preferred; for IPv6, + /// the first global or unique local address. Otherwise, the first link-local address is returned. + /// + /// Unicast addresses of each network interface. + /// The address family to search for. + /// The selected IP address, or if there is no address of the family. + public static IPAddress SelectLocalIPAddress(IEnumerable addressesPerNetworkInterface, + AddressFamily addressFamily) + { + var candidates = addressesPerNetworkInterface + .SelectMany(x => x) + .Where(x => x.AddressFamily == addressFamily) + .ToList(); - // Return first candidate if any found - if (candidates.Count != 0) - return candidates.First(); + return candidates.FirstOrDefault(x => !IsLinkLocal(x)) ?? candidates.FirstOrDefault(); + } - // Fallback to link-local addresses - var firstWithLinkLocal = networkInterfaces - .FirstOrDefault(ni => ni.IPv6AddressLinkLocal.Length != 0); + /// + /// Checks if the IP address is a link-local address (IPv4 169.254.0.0/16, IPv6 fe80::/10). + /// + /// IP address. + /// if the IP address is link-local. + public static bool IsLinkLocal(IPAddress ipAddress) + { + if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6) + return ipAddress.IsIPv6LinkLocal; - if (firstWithLinkLocal != null) - return firstWithLinkLocal.IPv6AddressLinkLocal.First(); - break; - } - } + var bytes = ipAddress.GetAddressBytes(); - return null; + return bytes[0] == 169 && bytes[1] == 254; } /// @@ -442,26 +439,41 @@ public static Task DetectGatewayFromLocalIPAddressAsync(IPAddress loc /// /// Attempts to determine the default gateway address associated with the specified local IP address. /// - /// This method searches all available network interfaces to find one that has the specified - /// local IP address assigned. If found, it returns the first associated gateway address for that interface and - /// address family. Returns null if the local IP address is not assigned to any interface or if no gateway is - /// configured. + /// All network interfaces are searched (also VPN adapters, e.g. PPP or tunnel, which are not shown in the + /// application) and only their addresses are read (no PowerShell / registry like ). + /// See . /// The local IP address for which to detect the corresponding gateway. Must be either an IPv4 or IPv6 address. /// An IPAddress representing the default gateway for the specified local IP address, or null if no matching gateway /// is found. private static IPAddress DetectGatewayFromLocalIPAddress(IPAddress localIPAddress) { - foreach (var networkInterface in GetNetworkInterfaces()) + var networkInterfaces = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces() + .Select(x => x.GetIPProperties()) + .Select(x => (x.UnicastAddresses.Select(y => y.Address).ToArray(), + x.GatewayAddresses.Select(y => y.Address).ToArray())); + + return SelectGateway(networkInterfaces, localIPAddress); + } + + /// + /// Selects the gateway of the first network interface that has the local IP address assigned. The scope id of IPv6 + /// addresses is ignored. Unspecified gateways (0.0.0.0 / ::, e.g. some VPN adapters) are skipped. + /// + /// Unicast and gateway addresses of each network interface. + /// The local IP address (IPv4 or IPv6). + /// The first gateway of the same address family, or if there is none. + public static IPAddress SelectGateway(IEnumerable<(IPAddress[] Addresses, IPAddress[] Gateways)> networkInterfaces, + IPAddress localIPAddress) + { + var local = IPAddressHelper.WithoutScopeId(localIPAddress); + + foreach (var (addresses, gateways) in networkInterfaces) { - switch (localIPAddress.AddressFamily) - { - // IPv4 - case AddressFamily.InterNetwork when networkInterface.IPv4Address.Any(x => x.Item1.Equals(localIPAddress)): - return networkInterface.IPv4Gateway.FirstOrDefault(); - // IPv6 - case AddressFamily.InterNetworkV6 when networkInterface.IPv6Address.Contains(localIPAddress): - return networkInterface.IPv6Gateway.FirstOrDefault(); - } + if (!addresses.Any(x => IPAddressHelper.WithoutScopeId(x).Equals(local))) + continue; + + return gateways.FirstOrDefault(x => x.AddressFamily == localIPAddress.AddressFamily && + !x.Equals(IPAddress.Any) && !x.Equals(IPAddress.IPv6Any)); } return null; diff --git a/Source/NETworkManager.Tests/Network/NetworkInterfaceDetectionTests.cs b/Source/NETworkManager.Tests/Network/NetworkInterfaceDetectionTests.cs new file mode 100644 index 0000000000..42ba33f902 --- /dev/null +++ b/Source/NETworkManager.Tests/Network/NetworkInterfaceDetectionTests.cs @@ -0,0 +1,119 @@ +using System.Net; +using System.Net.Sockets; +using NETworkManager.Models.Network; +using Xunit; + +namespace NETworkManager.Tests.Network; + +public class NetworkInterfaceDetectionTests +{ + private static IPAddress[] Addresses(params string[] addresses) => + [.. System.Linq.Enumerable.Select(addresses, IPAddress.Parse)]; + + [Fact] + public void SelectLocalIPAddress_IPv4_PrefersNonLinkLocal() + { + // e.g. a disconnected adapter without DHCP (169.254.x.x) before the connected one + var result = NetworkInterface.SelectLocalIPAddress( + [Addresses("169.254.10.20", "fe80::1"), Addresses("192.168.1.10")], AddressFamily.InterNetwork); + + Assert.Equal(IPAddress.Parse("192.168.1.10"), result); + } + + [Fact] + public void SelectLocalIPAddress_IPv4_OnlyLinkLocal() + { + var result = NetworkInterface.SelectLocalIPAddress([Addresses("169.254.10.20")], AddressFamily.InterNetwork); + + Assert.Equal(IPAddress.Parse("169.254.10.20"), result); + } + + [Fact] + public void SelectLocalIPAddress_IPv6_PrefersGlobalOrUniqueLocal() + { + var result = NetworkInterface.SelectLocalIPAddress( + [Addresses("192.168.1.10", "fe80::1"), Addresses("fe80::2", "fd00::10")], AddressFamily.InterNetworkV6); + + Assert.Equal(IPAddress.Parse("fd00::10"), result); + } + + [Fact] + public void SelectLocalIPAddress_IPv6_FallbackLinkLocal() + { + var result = NetworkInterface.SelectLocalIPAddress([Addresses("192.168.1.10", "fe80::1")], + AddressFamily.InterNetworkV6); + + Assert.Equal(IPAddress.Parse("fe80::1"), result); + } + + [Fact] + public void SelectLocalIPAddress_NoAddressOfFamily() + { + Assert.Null(NetworkInterface.SelectLocalIPAddress([Addresses("fe80::1")], AddressFamily.InterNetwork)); + Assert.Null(NetworkInterface.SelectLocalIPAddress([], AddressFamily.InterNetworkV6)); + } + + [Theory] + [InlineData("169.254.0.1", true)] + [InlineData("169.253.0.1", false)] + [InlineData("192.168.1.1", false)] + [InlineData("fe80::1", true)] + [InlineData("2001:db8::1", false)] + [InlineData("fd00::1", false)] + public void IsLinkLocal(string ipAddress, bool expected) + { + Assert.Equal(expected, NetworkInterface.IsLinkLocal(IPAddress.Parse(ipAddress))); + } + + [Fact] + public void SelectGateway_GatewayOfTheInterfaceWithTheLocalAddress() + { + var result = NetworkInterface.SelectGateway( + [ + (Addresses("10.0.0.5"), Addresses("10.0.0.1")), + (Addresses("192.168.1.10", "fe80::10"), Addresses("fe80::1", "192.168.1.1")) + ], IPAddress.Parse("192.168.1.10")); + + Assert.Equal(IPAddress.Parse("192.168.1.1"), result); + } + + [Fact] + public void SelectGateway_IPv6() + { + var result = NetworkInterface.SelectGateway( + [(Addresses("192.168.1.10", "2001:db8::10"), Addresses("192.168.1.1", "fe80::1"))], + IPAddress.Parse("2001:db8::10")); + + Assert.Equal(IPAddress.Parse("fe80::1"), result); + } + + [Fact] + public void SelectGateway_IgnoresScopeId() + { + var local = IPAddress.Parse("fe80::10"); + local.ScopeId = 12; + + var result = NetworkInterface.SelectGateway([(Addresses("fe80::10"), Addresses("fe80::1"))], local); + + Assert.Equal(IPAddress.Parse("fe80::1"), result); + } + + [Fact] + public void SelectGateway_SkipsUnspecifiedGateway() + { + // e.g. a VPN adapter (on-link default route) + var result = NetworkInterface.SelectGateway([(Addresses("10.8.0.2"), Addresses("0.0.0.0"))], + IPAddress.Parse("10.8.0.2")); + + Assert.Null(result); + } + + [Fact] + public void SelectGateway_LocalAddressNotFound() + { + var result = NetworkInterface.SelectGateway([(Addresses("192.168.1.10"), Addresses("192.168.1.1"))], + IPAddress.Parse("10.0.0.5")); + + Assert.Null(result); + } +} diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 152ff51f6f..d897996aee 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -52,6 +52,7 @@ Release date: **xx.xx.2026** **Dashboard** - Switching back to the dashboard checks the network connection only if the last check is at least 60 seconds old (or the network / the dashboard settings changed), instead of on every switch between the tools. **F5** and the refresh button always check. [#PR](PRLINK) +- The network connection check is faster (also at startup and in the status window): the local IP address and the gateway are read directly from the network adapters instead of querying all adapter details incl. PowerShell up to four times per check. This also speeds up the detection of the local IP address in the **IP Scanner** when no route is available. [#PR](PRLINK) ## Bug Fixes @@ -130,6 +131,7 @@ Release date: **xx.xx.2026** - Fixed the network connection check getting stuck (all values loading until the next refresh) when the refresh was used several times while a check was running. A refresh during a check now repeats the check once it has finished. [#PR](PRLINK) - Fixed the network connection widget (dashboard and status window) not updating when **Check public IP address** was changed in the settings until the application was restarted: an old public IP address could be shown as current. [#PR](PRLINK) - Fixed the network connection not being checked again when the network changed while the dashboard was open (e.g. a cable unplugged or a VPN connected), although the documentation says so. If the dashboard is not open, it is checked when it is opened again. [#PR](PRLINK) +- Fixed the gateway / router not being found (shown as failed although the internet works) for VPN connections whose adapter is not an Ethernet or Wi-Fi adapter (e.g. the Windows VPN client with IKEv2 / SSTP). A VPN adapter without a gateway is no longer shown with the gateway `0.0.0.0`. [#PR](PRLINK) **Status window** From 85f3b6bfbe3316a6f584b012ab988fc7e8718642 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:19:25 +0100 Subject: [PATCH 08/56] Refactor: Dashboard: One method to detect the local IPv4 / IPv6 address (R1) Co-Authored-By: Claude Opus 5.5 --- .../NetworkConnectionWidgetViewModel.cs | 79 +++++-------------- 1 file changed, 20 insertions(+), 59 deletions(-) diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index 001e3c21f7..118bbc1977 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -185,8 +185,10 @@ private async Task RunTask() // Detect the local IPv4/IPv6 address once and share it between the Computer and Router // checks below, instead of each of them redetecting it independently (both used to // trigger their own, potentially PowerShell-backed, network interface lookup). - var localIPv4Task = DetectLocalIPv4Async(); - var localIPv6Task = DetectLocalIPv6Async(); + var localIPv4Task = DetectLocalIPAddressAsync(SettingsManager.Current.Dashboard_PublicIPv4Address, + AddressFamily.InterNetwork); + var localIPv6Task = DetectLocalIPAddressAsync(SettingsManager.Current.Dashboard_PublicIPv6Address, + AddressFamily.InterNetworkV6); await Task.WhenAll(localIPv4Task, localIPv6Task); @@ -248,73 +250,32 @@ private void SetScreenshotData() } /// - /// Detects the local IPv4 address, based on routing to the configured public IPv4 address, with - /// a fallback to detection based on the network interfaces. + /// Detects the local IP address, based on routing to the configured public IP address (setting), with a fallback + /// to detection based on the network interfaces. /// - private static async Task DetectLocalIPv4Async() + /// Public IPv4 or IPv6 address (setting) used to find the route. + /// IPv4 or IPv6. + /// Local IP address, or null if none was found. + private static async Task DetectLocalIPAddressAsync(string remoteIPAddress, AddressFamily addressFamily) { - Log.Debug($"{nameof(DetectLocalIPv4Async)} - Detecting local IPv4 address..."); + Log.Debug($"{nameof(DetectLocalIPAddressAsync)} - Detecting local {addressFamily} address..."); - IPAddress remoteIPv4 = null; + IPAddress detected = null; - try - { - remoteIPv4 = IPAddress.Parse(SettingsManager.Current.Dashboard_PublicIPv4Address); - } - catch (Exception ex) - { - Log.Warn($"{nameof(DetectLocalIPv4Async)} - Invalid Dashboard_PublicIPv4Address setting, skipping routing based detection.", ex); - } - - var detected = remoteIPv4 != null - ? await NetworkInterface.DetectLocalIPAddressBasedOnRoutingAsync(remoteIPv4) - : null; - - if (detected == null) - { - Log.Debug($"{nameof(DetectLocalIPv4Async)} - Local IPv4 address detection via routing failed, trying network interfaces..."); - detected = await NetworkInterface.DetectLocalIPAddressFromNetworkInterfaceAsync(AddressFamily.InterNetwork); - } - - Log.Debug(detected != null - ? $"{nameof(DetectLocalIPv4Async)} - Local IPv4 address detected: " + detected - : $"{nameof(DetectLocalIPv4Async)} - Local IPv4 address not detected."); - - return detected; - } - - /// - /// Detects the local IPv6 address, based on routing to the configured public IPv6 address, with - /// a fallback to detection based on the network interfaces. - /// - private static async Task DetectLocalIPv6Async() - { - Log.Debug($"{nameof(DetectLocalIPv6Async)} - Detecting local IPv6 address..."); - - IPAddress remoteIPv6 = null; - - try - { - remoteIPv6 = IPAddress.Parse(SettingsManager.Current.Dashboard_PublicIPv6Address); - } - catch (Exception ex) - { - Log.Warn($"{nameof(DetectLocalIPv6Async)} - Invalid Dashboard_PublicIPv6Address setting, skipping routing based detection.", ex); - } - - var detected = remoteIPv6 != null - ? await NetworkInterface.DetectLocalIPAddressBasedOnRoutingAsync(remoteIPv6) - : null; + if (IPAddress.TryParse(remoteIPAddress, out var remote) && remote.AddressFamily == addressFamily) + detected = await NetworkInterface.DetectLocalIPAddressBasedOnRoutingAsync(remote); + else + Log.Warn($"{nameof(DetectLocalIPAddressAsync)} - Invalid public {addressFamily} address \"{remoteIPAddress}\" in the settings, skipping routing based detection."); if (detected == null) { - Log.Debug($"{nameof(DetectLocalIPv6Async)} - Local IPv6 address detection via routing failed, trying network interfaces..."); - detected = await NetworkInterface.DetectLocalIPAddressFromNetworkInterfaceAsync(AddressFamily.InterNetworkV6); + Log.Debug($"{nameof(DetectLocalIPAddressAsync)} - Local {addressFamily} address detection via routing failed, trying network interfaces..."); + detected = await NetworkInterface.DetectLocalIPAddressFromNetworkInterfaceAsync(addressFamily); } Log.Debug(detected != null - ? $"{nameof(DetectLocalIPv6Async)} - Local IPv6 address detected: " + detected - : $"{nameof(DetectLocalIPv6Async)} - Local IPv6 address not detected."); + ? $"{nameof(DetectLocalIPAddressAsync)} - Local {addressFamily} address detected: {detected}" + : $"{nameof(DetectLocalIPAddressAsync)} - Local {addressFamily} address not detected."); return detected; } From 4190ad1d17c1188e349d6aad8a8141104327dd9d Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:20:46 +0100 Subject: [PATCH 09/56] Refactor: Dashboard: Row template for the network connection widget (R4) 9 copied rows (loading / state / label / value) and 3 copies of the implicit styles -> one DataTemplate (label via Tag, shared label column width per card). Same margins, no visual change intended (to check on Windows). Co-Authored-By: Claude Opus 5.5 --- .../Views/NetworkConnectionWidgetView.xaml | 343 +++++++----------- 1 file changed, 134 insertions(+), 209 deletions(-) diff --git a/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml b/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml index c96ddd6586..bc2eea5d3e 100644 --- a/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml +++ b/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml @@ -19,6 +19,47 @@ + + + + + + + + + + + + + + + + + + + + + @@ -32,225 +73,109 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + From 132cbf061906daa9cc6103c45393f9e95432cdf1 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:23:53 +0100 Subject: [PATCH 10/56] Feature: Dashboard: Warning for link-local / not routed IPv4, info if IPv6 is not available (B4) NetworkConnectionCheck.GetLocalIPAddressResult (Models) + tests (T1); reason as tooltip of the state icon (ConnectionCheckItem.Message, ResourceIdentifier.ConnectionCheckReason). Co-Authored-By: Claude Opus 5.5 --- .../ResourceIdentifier.cs | 1 + .../Resources/Strings.Designer.cs | 36 +++++ .../Resources/Strings.resx | 12 ++ .../Network/ConnectionCheckReason.cs | 34 ++++ .../Network/NetworkConnectionCheck.cs | 49 ++++++ .../Network/NetworkConnectionCheckTests.cs | 41 +++++ .../ViewModels/ConnectionCheckItem.cs | 32 +++- .../NetworkConnectionWidgetViewModel.cs | 148 +++++++++++------- .../Views/NetworkConnectionWidgetView.xaml | 3 +- Website/docs/application/dashboard.md | 11 ++ Website/docs/changelog/next-release.md | 1 + 11 files changed, 312 insertions(+), 56 deletions(-) create mode 100644 Source/NETworkManager.Models/Network/ConnectionCheckReason.cs create mode 100644 Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs create mode 100644 Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs diff --git a/Source/NETworkManager.Localization/ResourceIdentifier.cs b/Source/NETworkManager.Localization/ResourceIdentifier.cs index 03f97b2f4f..c812c623c9 100644 --- a/Source/NETworkManager.Localization/ResourceIdentifier.cs +++ b/Source/NETworkManager.Localization/ResourceIdentifier.cs @@ -6,6 +6,7 @@ public enum ResourceIdentifier AccentGlowIntensity, AnimationMode, ApplicationName, + ConnectionCheckReason, LLDPCDPProtocol, IPStatus, PortState, diff --git a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs index 0f7c6c2a87..efb85311dd 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs +++ b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs @@ -2611,6 +2611,42 @@ public static string Connection { } } + /// + /// Looks up a localized string similar to Link-local address (169.254.x.x): the network adapter did not get an IPv4 address from a DHCP server.. + /// + public static string ConnectionCheckReason_IPv4LinkLocal { + get { + return ResourceManager.GetString("ConnectionCheckReason_IPv4LinkLocal", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No IPv6 connection. The network or the internet provider may not support IPv6.. + /// + public static string ConnectionCheckReason_IPv6NotAvailable { + get { + return ResourceManager.GetString("ConnectionCheckReason_IPv6NotAvailable", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No IPv4 address.. + /// + public static string ConnectionCheckReason_NoIPv4Address { + get { + return ResourceManager.GetString("ConnectionCheckReason_NoIPv4Address", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No route to the internet (no default gateway). The address of the first active network adapter is shown.. + /// + public static string ConnectionCheckReason_NoRoute { + get { + return ResourceManager.GetString("ConnectionCheckReason_NoRoute", resourceCulture); + } + } + /// /// Looks up a localized string similar to Connections. /// diff --git a/Source/NETworkManager.Localization/Resources/Strings.resx b/Source/NETworkManager.Localization/Resources/Strings.resx index 1dbc1ebe6c..5994a7bce9 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.resx @@ -5699,4 +5699,16 @@ Do you want to start the scan? Searching for network adapters... + + No IPv4 address. + + + Link-local address (169.254.x.x): the network adapter did not get an IPv4 address from a DHCP server. + + + No route to the internet (no default gateway). The address of the first active network adapter is shown. + + + No IPv6 connection. The network or the internet provider may not support IPv6. + \ No newline at end of file diff --git a/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs b/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs new file mode 100644 index 0000000000..daf55da731 --- /dev/null +++ b/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs @@ -0,0 +1,34 @@ +namespace NETworkManager.Models.Network; + +/// +/// Reason of the state of a network connection check (e.g. Computer > IPv4), shown as tooltip of the state icon. +/// Localized via ResourceIdentifier.ConnectionCheckReason. +/// +public enum ConnectionCheckReason +{ + /// + /// No reason (e.g. the check was successful). + /// + None, + + /// + /// The computer has no IPv4 address. + /// + NoIPv4Address, + + /// + /// The computer has only a link-local IPv4 address (169.254.x.x): no address from a DHCP server. + /// + IPv4LinkLocal, + + /// + /// There is no route to the public IP address (no default gateway); the address of the first active network + /// adapter is shown. + /// + NoRoute, + + /// + /// The computer has no routed IPv6 address (only link-local or none), e.g. the network doesn't support IPv6. + /// + IPv6NotAvailable +} diff --git a/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs b/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs new file mode 100644 index 0000000000..a4ceb93090 --- /dev/null +++ b/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs @@ -0,0 +1,49 @@ +using System.Net; +using System.Net.Sockets; + +namespace NETworkManager.Models.Network; + +/// +/// Result of a network connection check (e.g. Computer > IPv4): the state and its reason. +/// +/// State of the check. +/// Reason of the state (shown as tooltip), if OK. +public sealed record ConnectionCheckResult(ConnectionState State, ConnectionCheckReason Reason = ConnectionCheckReason.None); + +/// +/// Decisions of the network connection check (dashboard widget and status window): which state a detected value +/// gets. The detection itself is done by the view model. +/// +public static class NetworkConnectionCheck +{ + /// + /// State of the local IP address of the computer. + /// + /// + /// IPv4: missing → critical; link-local (no DHCP server) or not routed (taken from the first active network + /// adapter) → warning. IPv6: missing, link-local only or not routed → info (the network or the internet provider + /// may not support IPv6, which is not an error). + /// + /// Local IP address, or null if none was detected. + /// IPv4 or IPv6. + /// The address was detected via the route to the public IP address (not the fallback). + /// State and reason. + public static ConnectionCheckResult GetLocalIPAddressResult(IPAddress ipAddress, AddressFamily addressFamily, + bool isRouted) + { + if (addressFamily == AddressFamily.InterNetworkV6) + return ipAddress == null || !isRouted || NetworkInterface.IsLinkLocal(ipAddress) + ? new ConnectionCheckResult(ConnectionState.Info, ConnectionCheckReason.IPv6NotAvailable) + : new ConnectionCheckResult(ConnectionState.OK); + + if (ipAddress == null) + return new ConnectionCheckResult(ConnectionState.Critical, ConnectionCheckReason.NoIPv4Address); + + if (NetworkInterface.IsLinkLocal(ipAddress)) + return new ConnectionCheckResult(ConnectionState.Warning, ConnectionCheckReason.IPv4LinkLocal); + + return isRouted + ? new ConnectionCheckResult(ConnectionState.OK) + : new ConnectionCheckResult(ConnectionState.Warning, ConnectionCheckReason.NoRoute); + } +} diff --git a/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs new file mode 100644 index 0000000000..95ef4459f9 --- /dev/null +++ b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs @@ -0,0 +1,41 @@ +using System.Net; +using System.Net.Sockets; +using NETworkManager.Models.Network; +using Xunit; + +namespace NETworkManager.Tests.Network; + +public class NetworkConnectionCheckTests +{ + private static IPAddress Ip(string ipAddress) => ipAddress == null ? null : IPAddress.Parse(ipAddress); + + [Theory] + [InlineData("192.168.1.10", true, ConnectionState.OK, ConnectionCheckReason.None)] + [InlineData(null, false, ConnectionState.Critical, ConnectionCheckReason.NoIPv4Address)] + // DHCP failed (#3288: the address is still shown) + [InlineData("169.254.10.20", false, ConnectionState.Warning, ConnectionCheckReason.IPv4LinkLocal)] + [InlineData("169.254.10.20", true, ConnectionState.Warning, ConnectionCheckReason.IPv4LinkLocal)] + // No route: address of the first active network adapter (fallback) + [InlineData("192.168.1.10", false, ConnectionState.Warning, ConnectionCheckReason.NoRoute)] + public void GetLocalIPAddressResult_IPv4(string ipAddress, bool isRouted, ConnectionState state, + ConnectionCheckReason reason) + { + Assert.Equal(new ConnectionCheckResult(state, reason), + NetworkConnectionCheck.GetLocalIPAddressResult(Ip(ipAddress), AddressFamily.InterNetwork, isRouted)); + } + + [Theory] + [InlineData("2001:db8::10", true, ConnectionState.OK, ConnectionCheckReason.None)] + [InlineData("fd00::10", true, ConnectionState.OK, ConnectionCheckReason.None)] + // IPv4-only network: not an error + [InlineData(null, false, ConnectionState.Info, ConnectionCheckReason.IPv6NotAvailable)] + [InlineData("fe80::10", false, ConnectionState.Info, ConnectionCheckReason.IPv6NotAvailable)] + // Unique local address without a route to the internet (e.g. some routers) + [InlineData("fd00::10", false, ConnectionState.Info, ConnectionCheckReason.IPv6NotAvailable)] + public void GetLocalIPAddressResult_IPv6(string ipAddress, bool isRouted, ConnectionState state, + ConnectionCheckReason reason) + { + Assert.Equal(new ConnectionCheckResult(state, reason), + NetworkConnectionCheck.GetLocalIPAddressResult(Ip(ipAddress), AddressFamily.InterNetworkV6, isRouted)); + } +} diff --git a/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs b/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs index 202b832fc3..55417a9294 100644 --- a/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs +++ b/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs @@ -1,3 +1,4 @@ +using NETworkManager.Localization; using NETworkManager.Models.Network; using NETworkManager.Utilities; @@ -57,6 +58,23 @@ public ConnectionState State } } = ConnectionState.None; + /// + /// Gets or sets the reason of the state (e.g. why it is a warning), shown as tooltip of the state icon. null + /// if there is nothing to explain. + /// + public string Message + { + get; + set + { + if (value == field) + return; + + field = value; + OnPropertyChanged(); + } + } + /// /// Resets the item to its initial "checking" state. /// @@ -65,15 +83,27 @@ public void Reset() IsChecking = true; Value = ""; State = ConnectionState.None; + Message = null; } /// /// Completes the check with the given value and state. /// - public void Complete(string value, ConnectionState state) + public void Complete(string value, ConnectionState state, string message = null) { Value = value; State = state; + Message = message; IsChecking = false; } + + /// + /// Completes the check with the given value and the state and (localized) reason of the result. + /// + public void Complete(string value, ConnectionCheckResult result) + { + Complete(value, result.State, result.Reason == ConnectionCheckReason.None + ? null + : ResourceTranslator.Translate(ResourceIdentifier.ConnectionCheckReason, result.Reason)); + } } diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index 118bbc1977..aabf770d39 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -192,16 +192,22 @@ private async Task RunTask() await Task.WhenAll(localIPv4Task, localIPv6Task); - var localIPv4 = localIPv4Task.Result; - var localIPv6 = localIPv6Task.Result; + var (localIPv4, isIPv4Routed) = localIPv4Task.Result; + var (localIPv6, isIPv6Routed) = localIPv6Task.Result; - SetAddressResult(ComputerIPv4, localIPv4); - SetAddressResult(ComputerIPv6, localIPv6); + var computerIPv4Result = NetworkConnectionCheck.GetLocalIPAddressResult(localIPv4, AddressFamily.InterNetwork, isIPv4Routed); + var computerIPv6Result = NetworkConnectionCheck.GetLocalIPAddressResult(localIPv6, AddressFamily.InterNetworkV6, isIPv6Routed); + + ComputerIPv4.Complete(localIPv4?.ToString() ?? "-/-", computerIPv4Result); + ComputerIPv6.Complete(localIPv6?.ToString() ?? "-/-", computerIPv6Result); + + // Without a routed IPv6 address, the IPv6 checks of the router and the internet are not available + var isIPv6Available = computerIPv6Result.State == ConnectionState.OK; await Task.WhenAll( - CheckConnectionComputerDnsAsync(), - CheckConnectionRouterAsync(localIPv4, localIPv6), - CheckConnectionInternetAsync() + CheckConnectionComputerDnsAsync(localIPv4, isIPv6Available ? localIPv6 : null), + CheckConnectionRouterAsync(localIPv4, isIPv6Available ? localIPv6 : null), + CheckConnectionInternetAsync(isIPv6Available) ); } @@ -255,8 +261,9 @@ private void SetScreenshotData() /// /// Public IPv4 or IPv6 address (setting) used to find the route. /// IPv4 or IPv6. - /// Local IP address, or null if none was found. - private static async Task DetectLocalIPAddressAsync(string remoteIPAddress, AddressFamily addressFamily) + /// Local IP address (null if none was found) and whether it was detected via the route. + private static async Task<(IPAddress Address, bool IsRouted)> DetectLocalIPAddressAsync(string remoteIPAddress, + AddressFamily addressFamily) { Log.Debug($"{nameof(DetectLocalIPAddressAsync)} - Detecting local {addressFamily} address..."); @@ -267,27 +274,37 @@ private static async Task DetectLocalIPAddressAsync(string remoteIPAd else Log.Warn($"{nameof(DetectLocalIPAddressAsync)} - Invalid public {addressFamily} address \"{remoteIPAddress}\" in the settings, skipping routing based detection."); - if (detected == null) + var isRouted = detected != null; + + if (!isRouted) { Log.Debug($"{nameof(DetectLocalIPAddressAsync)} - Local {addressFamily} address detection via routing failed, trying network interfaces..."); detected = await NetworkInterface.DetectLocalIPAddressFromNetworkInterfaceAsync(addressFamily); } Log.Debug(detected != null - ? $"{nameof(DetectLocalIPAddressAsync)} - Local {addressFamily} address detected: {detected}" + ? $"{nameof(DetectLocalIPAddressAsync)} - Local {addressFamily} address detected: {detected} (routed: {isRouted})" : $"{nameof(DetectLocalIPAddressAsync)} - Local {addressFamily} address not detected."); - return detected; + return (detected, isRouted); } /// - /// Applies a detected address to a . + /// Applies a detected gateway to a . /// - private static void SetAddressResult(ConnectionCheckItem item, IPAddress detected) + private static void SetGatewayResult(ConnectionCheckItem item, IPAddress detected) { item.Complete(detected?.ToString() ?? "-/-", detected != null ? ConnectionState.OK : ConnectionState.Critical); } + /// + /// Marks an IPv6 check as not available (the computer has no routed IPv6 address). + /// + private static void SetIPv6NotAvailable(ConnectionCheckItem item) + { + item.Complete("-/-", new ConnectionCheckResult(ConnectionState.Info, ConnectionCheckReason.IPv6NotAvailable)); + } + /// /// Resolves the DNS (PTR) name for an address item, trying IPv4 first and falling back to IPv6. /// @@ -296,21 +313,22 @@ private static void SetAddressResult(ConnectionCheckItem item, IPAddress detecte /// routers and many ISPs don't configure reverse DNS) is reported as /// rather than - it's not a sign of a broken DNS setup. /// - private async Task ResolveDnsAsync(ConnectionCheckItem dnsItem, ConnectionCheckItem addressIPv4, ConnectionCheckItem addressIPv6, string context) + private static async Task ResolveDnsAsync(ConnectionCheckItem dnsItem, IPAddress ipv4Address, IPAddress ipv6Address, + string context) { DNSClientResultString ipv4Result = null; DNSClientResultString ipv6Result = null; - if (addressIPv4.State == ConnectionState.OK) + if (ipv4Address != null) { Log.Debug($"{context} > {nameof(ResolveDnsAsync)} - Resolving DNS based on IPv4..."); - ipv4Result = await DNSClient.GetInstance().ResolvePtrAsync(IPAddress.Parse(addressIPv4.Value)); + ipv4Result = await DNSClient.GetInstance().ResolvePtrAsync(ipv4Address); } - if (ipv4Result is not { HasError: false } && addressIPv6.State == ConnectionState.OK) + if (ipv4Result is not { HasError: false } && ipv6Address != null) { Log.Debug($"{context} > {nameof(ResolveDnsAsync)} - Resolving DNS based on IPv6..."); - ipv6Result = await DNSClient.GetInstance().ResolvePtrAsync(IPAddress.Parse(addressIPv6.Value)); + ipv6Result = await DNSClient.GetInstance().ResolvePtrAsync(ipv6Address); } // Prefer a successful resolution from either family. If neither succeeded, a clean @@ -340,12 +358,14 @@ private async Task ResolveDnsAsync(ConnectionCheckItem dnsItem, ConnectionCheckI /// /// Resolves the computer's DNS (PTR) name. /// - private Task CheckConnectionComputerDnsAsync() + /// The local IPv4 address, or null. + /// The local IPv6 address, or null (also if IPv6 is not available). + private Task CheckConnectionComputerDnsAsync(IPAddress localIPv4, IPAddress localIPv6) { return Task.Run(async () => { Log.Debug($"{nameof(CheckConnectionComputerDnsAsync)} - Checking computer DNS..."); - await ResolveDnsAsync(ComputerDNS, ComputerIPv4, ComputerIPv6, nameof(CheckConnectionComputerDnsAsync)); + await ResolveDnsAsync(ComputerDNS, localIPv4, localIPv6, nameof(CheckConnectionComputerDnsAsync)); Log.Debug($"{nameof(CheckConnectionComputerDnsAsync)} - Computer DNS check completed."); }); } @@ -354,7 +374,7 @@ private Task CheckConnectionComputerDnsAsync() /// Checks the router connection asynchronously. /// /// The already-detected local IPv4 address, or null. - /// The already-detected local IPv6 address, or null. + /// The already-detected local IPv6 address, or null if IPv6 is not available. /// A task representing the asynchronous operation. private Task CheckConnectionRouterAsync(IPAddress localIPv4, IPAddress localIPv6) { @@ -369,19 +389,26 @@ private Task CheckConnectionRouterAsync(IPAddress localIPv4, IPAddress localIPv6 ? await NetworkInterface.DetectGatewayFromLocalIPAddressAsync(localIPv4) : null; - SetAddressResult(RouterIPv4, routerIPv4); + SetGatewayResult(RouterIPv4, routerIPv4); // Detect router IPv6 gateway - Log.Debug($"{nameof(CheckConnectionRouterAsync)} - Detecting router IPv6 address..."); + IPAddress routerIPv6 = null; - var routerIPv6 = localIPv6 != null - ? await NetworkInterface.DetectGatewayFromLocalIPAddressAsync(localIPv6) - : null; + if (localIPv6 != null) + { + Log.Debug($"{nameof(CheckConnectionRouterAsync)} - Detecting router IPv6 address..."); + + routerIPv6 = await NetworkInterface.DetectGatewayFromLocalIPAddressAsync(localIPv6); - SetAddressResult(RouterIPv6, routerIPv6); + SetGatewayResult(RouterIPv6, routerIPv6); + } + else + { + SetIPv6NotAvailable(RouterIPv6); + } // Resolve router DNS - await ResolveDnsAsync(RouterDNS, RouterIPv4, RouterIPv6, nameof(CheckConnectionRouterAsync)); + await ResolveDnsAsync(RouterDNS, routerIPv4, routerIPv6, nameof(CheckConnectionRouterAsync)); Log.Debug($"{nameof(CheckConnectionRouterAsync)} - Router connection check completed."); }); @@ -390,8 +417,9 @@ private Task CheckConnectionRouterAsync(IPAddress localIPv4, IPAddress localIPv6 /// /// Checks the internet connection asynchronously. /// + /// The computer has a routed IPv6 address (otherwise IPv6 is not checked). /// A task representing the asynchronous operation. - private Task CheckConnectionInternetAsync() + private Task CheckConnectionInternetAsync(bool isIPv6Available) { return Task.Run(async () => { @@ -401,6 +429,9 @@ private Task CheckConnectionInternetAsync() Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Checking internet connection..."); + IPAddress publicIPv4 = null; + IPAddress publicIPv6 = null; + // Detect public IPv4 and if it is reachable Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Detecting public IPv4 address..."); @@ -419,6 +450,7 @@ private Task CheckConnectionInternetAsync() if (match.Success) { Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv4 address detected: " + match.Value); + publicIPv4 = IPAddress.Parse(match.Value); InternetIPv4.Complete(match.Value, ConnectionState.OK); } else @@ -434,41 +466,49 @@ private Task CheckConnectionInternetAsync() InternetIPv4.Complete("-/-", ConnectionState.Critical); } - // Detect public IPv6 and if it is reachable - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Detecting public IPv6 address..."); - - var publicIPv6AddressAPI = SettingsManager.Current.Dashboard_UseCustomPublicIPv6AddressAPI - ? SettingsManager.Current.Dashboard_CustomPublicIPv6AddressAPI - : GlobalStaticConfiguration.Dashboard_PublicIPv6AddressAPI; - - try + // Detect public IPv6 and if it is reachable (only if the computer has a routed IPv6 address) + if (!isIPv6Available) { - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Checking public IPv6 address from: " + publicIPv6AddressAPI); + SetIPv6NotAvailable(InternetIPv6); + } + else + { + Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Detecting public IPv6 address..."); - var httpResponse = await PublicIPHttpClient.GetAsync(publicIPv6AddressAPI); - var result = await httpResponse.Content.ReadAsStringAsync(); - var match = Regex.Match(result, RegexHelper.IPv6AddressRegex); + var publicIPv6AddressAPI = SettingsManager.Current.Dashboard_UseCustomPublicIPv6AddressAPI + ? SettingsManager.Current.Dashboard_CustomPublicIPv6AddressAPI + : GlobalStaticConfiguration.Dashboard_PublicIPv6AddressAPI; - if (match.Success) + try { - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv6 address detected: " + match.Value); - InternetIPv6.Complete(match.Value, ConnectionState.OK); + Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Checking public IPv6 address from: " + publicIPv6AddressAPI); + + var httpResponse = await PublicIPHttpClient.GetAsync(publicIPv6AddressAPI); + var result = await httpResponse.Content.ReadAsStringAsync(); + var match = Regex.Match(result, RegexHelper.IPv6AddressRegex); + + if (match.Success) + { + Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv6 address detected: " + match.Value); + publicIPv6 = IPAddress.Parse(match.Value); + InternetIPv6.Complete(match.Value, ConnectionState.OK); + } + else + { + Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv6 address not detected due to invalid format."); + InternetIPv6.Complete("-/-", ConnectionState.Critical); + } } - else + catch (Exception ex) { - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv6 address not detected due to invalid format."); + Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv6 address not detected due to exception: " + ex.Message); + InternetIPv6.Complete("-/-", ConnectionState.Critical); } } - catch (Exception ex) - { - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv6 address not detected due to exception: " + ex.Message); - - InternetIPv6.Complete("-/-", ConnectionState.Critical); - } // Resolve internet DNS - await ResolveDnsAsync(InternetDNS, InternetIPv4, InternetIPv6, nameof(CheckConnectionInternetAsync)); + await ResolveDnsAsync(InternetDNS, publicIPv4, publicIPv6, nameof(CheckConnectionInternetAsync)); Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Internet connection check completed."); }); diff --git a/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml b/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml index bc2eea5d3e..9c950b98a6 100644 --- a/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml +++ b/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml @@ -39,7 +39,8 @@ IsActive="{Binding IsChecking}" /> + Visibility="{Binding IsChecking, Converter={StaticResource BooleanReverseToVisibilityCollapsedConverter}}" + ToolTip="{Binding Message}" /> Date: Wed, 25 Nov 2026 21:24:59 +0100 Subject: [PATCH 11/56] Fix: Dashboard: No IPv6 PTR lookup after a DNS server error (P3) DNS decision moved to NetworkConnectionCheck.ShouldResolveIPv6 / GetDNSResult (Models) + tests (T1). Nothing to resolve -> info. Co-Authored-By: Claude Opus 5.5 --- .../Resources/Strings.Designer.cs | 27 +++++++++ .../Resources/Strings.resx | 9 +++ .../Network/ConnectionCheckReason.cs | 17 +++++- .../Network/NetworkConnectionCheck.cs | 36 +++++++++++ .../Network/NetworkConnectionCheckTests.cs | 60 +++++++++++++++++++ .../NetworkConnectionWidgetViewModel.cs | 35 +++-------- Website/docs/application/dashboard.md | 6 +- Website/docs/changelog/next-release.md | 1 + 8 files changed, 159 insertions(+), 32 deletions(-) diff --git a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs index efb85311dd..44345e63ff 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs +++ b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs @@ -2611,6 +2611,15 @@ public static string Connection { } } + /// + /// Looks up a localized string similar to The DNS server did not answer or returned an error.. + /// + public static string ConnectionCheckReason_DNSError { + get { + return ResourceManager.GetString("ConnectionCheckReason_DNSError", resourceCulture); + } + } + /// /// Looks up a localized string similar to Link-local address (169.254.x.x): the network adapter did not get an IPv4 address from a DHCP server.. /// @@ -2629,6 +2638,15 @@ public static string ConnectionCheckReason_IPv6NotAvailable { } } + /// + /// Looks up a localized string similar to No IP address to resolve.. + /// + public static string ConnectionCheckReason_NoIPAddressToResolve { + get { + return ResourceManager.GetString("ConnectionCheckReason_NoIPAddressToResolve", resourceCulture); + } + } + /// /// Looks up a localized string similar to No IPv4 address.. /// @@ -2647,6 +2665,15 @@ public static string ConnectionCheckReason_NoRoute { } } + /// + /// Looks up a localized string similar to No DNS record (PTR) found for the IP address. Many networks don't have one, this is not an error.. + /// + public static string ConnectionCheckReason_PTRNotFound { + get { + return ResourceManager.GetString("ConnectionCheckReason_PTRNotFound", resourceCulture); + } + } + /// /// Looks up a localized string similar to Connections. /// diff --git a/Source/NETworkManager.Localization/Resources/Strings.resx b/Source/NETworkManager.Localization/Resources/Strings.resx index 5994a7bce9..7bceabfaeb 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.resx @@ -5711,4 +5711,13 @@ Do you want to start the scan? No IPv6 connection. The network or the internet provider may not support IPv6. + + No IP address to resolve. + + + No DNS record (PTR) found for the IP address. Many networks don't have one, this is not an error. + + + The DNS server did not answer or returned an error. + \ No newline at end of file diff --git a/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs b/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs index daf55da731..b513282c4c 100644 --- a/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs +++ b/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs @@ -30,5 +30,20 @@ public enum ConnectionCheckReason /// /// The computer has no routed IPv6 address (only link-local or none), e.g. the network doesn't support IPv6. /// - IPv6NotAvailable + IPv6NotAvailable, + + /// + /// There is no IP address to resolve the DNS name (PTR) for. + /// + NoIPAddressToResolve, + + /// + /// The DNS server answered, but there is no DNS record (PTR) for the IP address (common for private addresses). + /// + PTRNotFound, + + /// + /// The DNS server did not answer or returned an error. + /// + DNSError } diff --git a/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs b/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs index a4ceb93090..950b9c192d 100644 --- a/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs +++ b/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs @@ -1,5 +1,6 @@ using System.Net; using System.Net.Sockets; +using NETworkManager.Utilities; namespace NETworkManager.Models.Network; @@ -46,4 +47,39 @@ public static ConnectionCheckResult GetLocalIPAddressResult(IPAddress ipAddress, ? new ConnectionCheckResult(ConnectionState.OK) : new ConnectionCheckResult(ConnectionState.Warning, ConnectionCheckReason.NoRoute); } + + /// + /// Decides whether the DNS name (PTR) is also resolved for the IPv6 address: if the IPv4 address was not resolved + /// or has no record. Not after a DNS server error, the same server would fail again (and the timeout doubles). + /// + /// Result of the IPv4 lookup, or null if there was no IPv4 address. + /// if the IPv6 address should be resolved. + public static bool ShouldResolveIPv6(DNSClientResultString ipv4Result) + { + return ipv4Result is null or { HasError: true, IsNotFound: true }; + } + + /// + /// State of the DNS name (PTR) of the IPv4 / IPv6 address: a resolved name of either address is OK. Otherwise a + /// clean "not found" of either address is info (many networks have no reverse DNS), not a broken DNS setup. + /// + /// Result of the IPv4 lookup, or null if not resolved. + /// Result of the IPv6 lookup, or null if not resolved. + /// State and reason, and the resolved name (null if none). + public static (ConnectionCheckResult Result, string Hostname) GetDNSResult(DNSClientResultString ipv4Result, + DNSClientResultString ipv6Result) + { + if (ipv4Result == null && ipv6Result == null) + return (new ConnectionCheckResult(ConnectionState.Info, ConnectionCheckReason.NoIPAddressToResolve), null); + + var resolved = ipv4Result is { HasError: false } ? ipv4Result : + ipv6Result is { HasError: false } ? ipv6Result : null; + + if (resolved != null) + return (new ConnectionCheckResult(ConnectionState.OK), resolved.Value); + + return ipv4Result is { IsNotFound: true } || ipv6Result is { IsNotFound: true } + ? (new ConnectionCheckResult(ConnectionState.Info, ConnectionCheckReason.PTRNotFound), null) + : (new ConnectionCheckResult(ConnectionState.Critical, ConnectionCheckReason.DNSError), null); + } } diff --git a/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs index 95ef4459f9..e0b0d0866f 100644 --- a/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs +++ b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs @@ -1,6 +1,7 @@ using System.Net; using System.Net.Sockets; using NETworkManager.Models.Network; +using NETworkManager.Utilities; using Xunit; namespace NETworkManager.Tests.Network; @@ -38,4 +39,63 @@ public void GetLocalIPAddressResult_IPv6(string ipAddress, bool isRouted, Connec Assert.Equal(new ConnectionCheckResult(state, reason), NetworkConnectionCheck.GetLocalIPAddressResult(Ip(ipAddress), AddressFamily.InterNetworkV6, isRouted)); } + + private static DNSClientResultString Resolved(string hostname) => new(hostname, "192.168.1.1:53"); + + private static DNSClientResultString NotFound() => new(true, "Non-Existent Domain", "192.168.1.1:53") + { IsNotFound = true }; + + private static DNSClientResultString Error() => new(true, "Timeout"); + + [Fact] + public void ShouldResolveIPv6() + { + Assert.True(NetworkConnectionCheck.ShouldResolveIPv6(null)); + Assert.True(NetworkConnectionCheck.ShouldResolveIPv6(NotFound())); + Assert.False(NetworkConnectionCheck.ShouldResolveIPv6(Resolved("pc.example.com"))); + // The same DNS server would time out again + Assert.False(NetworkConnectionCheck.ShouldResolveIPv6(Error())); + } + + [Fact] + public void GetDNSResult_ResolvedIPv4() + { + var (result, hostname) = NetworkConnectionCheck.GetDNSResult(Resolved("pc.example.com"), null); + + Assert.Equal(new ConnectionCheckResult(ConnectionState.OK), result); + Assert.Equal("pc.example.com", hostname); + } + + [Fact] + public void GetDNSResult_ResolvedIPv6AfterIPv4NotFound() + { + var (result, hostname) = NetworkConnectionCheck.GetDNSResult(NotFound(), Resolved("pc6.example.com")); + + Assert.Equal(ConnectionState.OK, result.State); + Assert.Equal("pc6.example.com", hostname); + } + + [Fact] + public void GetDNSResult_NotFoundWinsOverError() + { + // e.g. IPv4 has no PTR while IPv6 times out: no record, not a broken DNS setup + var (result, hostname) = NetworkConnectionCheck.GetDNSResult(NotFound(), Error()); + + Assert.Equal(new ConnectionCheckResult(ConnectionState.Info, ConnectionCheckReason.PTRNotFound), result); + Assert.Null(hostname); + } + + [Fact] + public void GetDNSResult_Error() + { + Assert.Equal(new ConnectionCheckResult(ConnectionState.Critical, ConnectionCheckReason.DNSError), + NetworkConnectionCheck.GetDNSResult(Error(), null).Result); + } + + [Fact] + public void GetDNSResult_NothingToResolve() + { + Assert.Equal(new ConnectionCheckResult(ConnectionState.Info, ConnectionCheckReason.NoIPAddressToResolve), + NetworkConnectionCheck.GetDNSResult(null, null).Result); + } } diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index aabf770d39..191e3cbd7a 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -306,13 +306,9 @@ private static void SetIPv6NotAvailable(ConnectionCheckItem item) } /// - /// Resolves the DNS (PTR) name for an address item, trying IPv4 first and falling back to IPv6. + /// Resolves the DNS (PTR) name of the IPv4 address, and of the IPv6 address if needed (see + /// / ). /// - /// - /// A PTR lookup that completes without a server error but simply has no record (e.g. most home - /// routers and many ISPs don't configure reverse DNS) is reported as - /// rather than - it's not a sign of a broken DNS setup. - /// private static async Task ResolveDnsAsync(ConnectionCheckItem dnsItem, IPAddress ipv4Address, IPAddress ipv6Address, string context) { @@ -325,34 +321,17 @@ private static async Task ResolveDnsAsync(ConnectionCheckItem dnsItem, IPAddress ipv4Result = await DNSClient.GetInstance().ResolvePtrAsync(ipv4Address); } - if (ipv4Result is not { HasError: false } && ipv6Address != null) + if (ipv6Address != null && NetworkConnectionCheck.ShouldResolveIPv6(ipv4Result)) { Log.Debug($"{context} > {nameof(ResolveDnsAsync)} - Resolving DNS based on IPv6..."); ipv6Result = await DNSClient.GetInstance().ResolvePtrAsync(ipv6Address); } - // Prefer a successful resolution from either family. If neither succeeded, a clean - // "not found" from either family still wins over a hard failure from the other - e.g. - // IPv4 has no PTR (NXDOMAIN) while IPv6 times out should show as "no record", not as a - // broken DNS setup. - var resolved = ipv4Result is { HasError: false } ? ipv4Result : ipv6Result is { HasError: false } ? ipv6Result : null; - var notFound = ipv4Result is { IsNotFound: true } || ipv6Result is { IsNotFound: true }; + var (result, hostname) = NetworkConnectionCheck.GetDNSResult(ipv4Result, ipv6Result); - if (resolved != null) - { - Log.Debug($"{context} > {nameof(ResolveDnsAsync)} - DNS resolved: " + resolved.Value); - dnsItem.Complete(resolved.Value, ConnectionState.OK); - } - else if (notFound) - { - Log.Debug($"{context} > {nameof(ResolveDnsAsync)} - DNS not resolved (no record found)."); - dnsItem.Complete("-/-", ConnectionState.Info); - } - else - { - Log.Debug($"{context} > {nameof(ResolveDnsAsync)} - DNS not resolved due to error. IPv4: {ipv4Result?.ErrorMessage ?? "n/a"} | IPv6: {ipv6Result?.ErrorMessage ?? "n/a"}"); - dnsItem.Complete("-/-", ConnectionState.Critical); - } + Log.Debug($"{context} > {nameof(ResolveDnsAsync)} - {result.State} ({result.Reason}): {hostname}. IPv4: {ipv4Result?.ErrorMessage ?? "n/a"} | IPv6: {ipv6Result?.ErrorMessage ?? "n/a"}"); + + dnsItem.Complete(hostname ?? "-/-", result); } /// diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index 6a4b459dac..bf9df0e672 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -12,14 +12,14 @@ The **Dashboard** shows the status of your computer's current network connection ## Network connection -The **Network connection** widget (also shown in the status window) checks the connection of the computer, the gateway / router and the internet, each for IPv4, IPv6 and DNS. The icon in front of each value shows the result, hover over it to see the reason: +The **Network connection** widget (also shown in the status window) checks the connection of the computer, the gateway / router and the internet, each for IPv4, IPv6 and DNS. The icon in front of each value shows the result, hover over it to see the reason. **DNS** is the DNS name (PTR record) of the IPv4 address, or of the IPv6 address if the IPv4 address has none: | Icon | Meaning | |------|---------| | Green | OK | | Yellow | Works partly or may not work, e.g. the computer has only a link-local IPv4 address (`169.254.x.x`, no address from a DHCP server) or no route to the internet (the address of the first active network adapter is shown) | -| Red | Failed, e.g. the computer has no IPv4 address | -| Gray | Information, e.g. no IPv6 connection: the network or the internet provider may not support IPv6 (the IPv6 checks of the router and the internet are skipped) | +| Red | Failed, e.g. the computer has no IPv4 address or the DNS server did not answer | +| Gray | Information, e.g. no IPv6 connection: the network or the internet provider may not support IPv6 (the IPv6 checks of the router and the internet are skipped), or no DNS name (PTR record) for the IP address, which many networks don't have | ### Keyboard shortcuts diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 667868d639..341b5cb31c 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -54,6 +54,7 @@ Release date: **xx.xx.2026** - Switching back to the dashboard checks the network connection only if the last check is at least 60 seconds old (or the network / the dashboard settings changed), instead of on every switch between the tools. **F5** and the refresh button always check. [#PR](PRLINK) - The network connection check is faster (also at startup and in the status window): the local IP address and the gateway are read directly from the network adapters instead of querying all adapter details incl. PowerShell up to four times per check. This also speeds up the detection of the local IP address in the **IP Scanner** when no route is available. [#PR](PRLINK) - The network connection shows a warning instead of OK if the computer has only a link-local IPv4 address (`169.254.x.x`, no address from a DHCP server) or no route to the internet. Without an IPv6 connection (e.g. the internet provider doesn't support IPv6), the IPv6 values are shown as information (gray) instead of failed (red), and the IPv6 address of the router and the internet are not checked. Hover over an icon to see the reason. [#PR](PRLINK) +- The DNS name (PTR) of the IPv6 address is no longer requested after the DNS server failed for the IPv4 address (the same server would time out again), so the network connection check finishes faster without a working DNS server. Without an IP address to resolve, the DNS value is shown as information instead of failed. [#PR](PRLINK) ## Bug Fixes From a4ca1b8258ec59adb0cf6ce03d34ff25e5ea3a73 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:26:14 +0100 Subject: [PATCH 12/56] Feature: Dashboard: Ping the gateway (B3) PingProbe (public) with the IP Scanner defaults (2 x 2000 ms, 32 bytes), IPv4 and IPv6 in parallel. NetworkConnectionCheck.GetGatewayResult + tests: no reply / no gateway but routed -> warning. Co-Authored-By: Claude Opus 5.5 --- .../Resources/Strings.Designer.cs | 18 +++++ .../Resources/Strings.resx | 6 ++ .../Network/ConnectionCheckReason.cs | 12 ++- .../Network/NetworkConnectionCheck.cs | 20 +++++ .../Network/PingProbe.cs | 5 +- .../GlobalStaticConfiguration.cs | 5 ++ .../Network/NetworkConnectionCheckTests.cs | 15 ++++ .../NetworkConnectionWidgetViewModel.cs | 73 ++++++++++++------- Website/docs/application/dashboard.md | 4 +- Website/docs/changelog/next-release.md | 1 + 10 files changed, 127 insertions(+), 32 deletions(-) diff --git a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs index 44345e63ff..23d378e452 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs +++ b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs @@ -2620,6 +2620,15 @@ public static string ConnectionCheckReason_DNSError { } } + /// + /// Looks up a localized string similar to The gateway did not reply to the ping. It may be offline or block ICMP.. + /// + public static string ConnectionCheckReason_GatewayNoReply { + get { + return ResourceManager.GetString("ConnectionCheckReason_GatewayNoReply", resourceCulture); + } + } + /// /// Looks up a localized string similar to Link-local address (169.254.x.x): the network adapter did not get an IPv4 address from a DHCP server.. /// @@ -2638,6 +2647,15 @@ public static string ConnectionCheckReason_IPv6NotAvailable { } } + /// + /// Looks up a localized string similar to No default gateway found on the network adapter (e.g. a VPN connection without a gateway).. + /// + public static string ConnectionCheckReason_NoGateway { + get { + return ResourceManager.GetString("ConnectionCheckReason_NoGateway", resourceCulture); + } + } + /// /// Looks up a localized string similar to No IP address to resolve.. /// diff --git a/Source/NETworkManager.Localization/Resources/Strings.resx b/Source/NETworkManager.Localization/Resources/Strings.resx index 7bceabfaeb..80a5b3e6ec 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.resx @@ -5720,4 +5720,10 @@ Do you want to start the scan? The DNS server did not answer or returned an error. + + No default gateway found on the network adapter (e.g. a VPN connection without a gateway). + + + The gateway did not reply to the ping. It may be offline or block ICMP. + \ No newline at end of file diff --git a/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs b/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs index b513282c4c..084f8ceb27 100644 --- a/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs +++ b/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs @@ -45,5 +45,15 @@ public enum ConnectionCheckReason /// /// The DNS server did not answer or returned an error. /// - DNSError + DNSError, + + /// + /// No default gateway was found on the network adapter of the local IP address (e.g. a VPN connection). + /// + NoGateway, + + /// + /// The gateway did not reply to the ping (it may be offline or block ICMP). + /// + GatewayNoReply } diff --git a/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs b/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs index 950b9c192d..38f698a7cc 100644 --- a/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs +++ b/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs @@ -82,4 +82,24 @@ public static (ConnectionCheckResult Result, string Hostname) GetDNSResult(DNSCl ? (new ConnectionCheckResult(ConnectionState.Info, ConnectionCheckReason.PTRNotFound), null) : (new ConnectionCheckResult(ConnectionState.Critical, ConnectionCheckReason.DNSError), null); } + + /// + /// State of the gateway (router): found and replies to the ping → OK; no reply → warning (some routers block + /// ICMP). Not found → warning if the local IP address is routed anyway (e.g. a VPN adapter without a gateway), + /// otherwise critical. + /// + /// Gateway, or null if none was found. + /// The local IP address was detected via the route to the public IP address. + /// The gateway replied to the ping. + /// State and reason. + public static ConnectionCheckResult GetGatewayResult(IPAddress gateway, bool isRouted, bool isReachable) + { + if (gateway == null) + return new ConnectionCheckResult(isRouted ? ConnectionState.Warning : ConnectionState.Critical, + ConnectionCheckReason.NoGateway); + + return isReachable + ? new ConnectionCheckResult(ConnectionState.OK) + : new ConnectionCheckResult(ConnectionState.Warning, ConnectionCheckReason.GatewayNoReply); + } } diff --git a/Source/NETworkManager.Models/Network/PingProbe.cs b/Source/NETworkManager.Models/Network/PingProbe.cs index cc109803bf..f9a6c17441 100644 --- a/Source/NETworkManager.Models/Network/PingProbe.cs +++ b/Source/NETworkManager.Models/Network/PingProbe.cs @@ -7,9 +7,10 @@ namespace NETworkManager.Models.Network; /// -/// Provides a shared ICMP echo (ping) probe used by and . +/// Provides a shared ICMP echo (ping) probe used by , and the +/// network connection check (dashboard). /// -internal static class PingProbe +public static class PingProbe { /// /// Pings the host. Another echo request is only sent if the previous one timed out (e.g. a lost packet), diff --git a/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs b/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs index e825803b83..aadcb15f83 100644 --- a/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs +++ b/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs @@ -146,6 +146,11 @@ public static class GlobalStaticConfiguration /// public static TimeSpan Dashboard_RecheckInterval => TimeSpan.FromSeconds(60); + // Ping of the gateway and the public IP address (same defaults as the IP Scanner / Port Scanner) + public static int Dashboard_PingTimeout => 2000; + public static int Dashboard_PingAttempts => 2; + public static int Dashboard_PingBuffer => 32; + // Application: Network Interface public static ExportFileType NetworkInterface_ExportFileType => ExportFileType.Csv; public static int NetworkInterface_BandwidthChartTime => 60; diff --git a/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs index e0b0d0866f..57a381d337 100644 --- a/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs +++ b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs @@ -98,4 +98,19 @@ public void GetDNSResult_NothingToResolve() Assert.Equal(new ConnectionCheckResult(ConnectionState.Info, ConnectionCheckReason.NoIPAddressToResolve), NetworkConnectionCheck.GetDNSResult(null, null).Result); } + + [Theory] + [InlineData("192.168.1.1", true, true, ConnectionState.OK, ConnectionCheckReason.None)] + // Some routers block ICMP + [InlineData("192.168.1.1", true, false, ConnectionState.Warning, ConnectionCheckReason.GatewayNoReply)] + // Routed via an adapter without a gateway (e.g. VPN) + [InlineData(null, true, false, ConnectionState.Warning, ConnectionCheckReason.NoGateway)] + // No route and no gateway (or no local IP address) + [InlineData(null, false, false, ConnectionState.Critical, ConnectionCheckReason.NoGateway)] + public void GetGatewayResult(string gateway, bool isRouted, bool isReachable, ConnectionState state, + ConnectionCheckReason reason) + { + Assert.Equal(new ConnectionCheckResult(state, reason), + NetworkConnectionCheck.GetGatewayResult(Ip(gateway), isRouted, isReachable)); + } } diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index 191e3cbd7a..f93203ce3a 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -5,6 +5,8 @@ using System.Net; using System.Net.Http; using System.Text.RegularExpressions; +using System.Threading; +using System.Net.NetworkInformation; using System.Threading.Tasks; using System.Windows.Input; using log4net; @@ -30,6 +32,11 @@ public class NetworkConnectionWidgetViewModel : ViewModelBase /// private static readonly HttpClient PublicIPHttpClient = new() { Timeout = TimeSpan.FromSeconds(10) }; + /// + /// Data sent with the ping of the gateway and the public IP address. + /// + private static readonly byte[] PingBuffer = new byte[GlobalStaticConfiguration.Dashboard_PingBuffer]; + #region Computer /// @@ -206,7 +213,7 @@ private async Task RunTask() await Task.WhenAll( CheckConnectionComputerDnsAsync(localIPv4, isIPv6Available ? localIPv6 : null), - CheckConnectionRouterAsync(localIPv4, isIPv6Available ? localIPv6 : null), + CheckConnectionRouterAsync(localIPv4, isIPv4Routed, isIPv6Available ? localIPv6 : null), CheckConnectionInternetAsync(isIPv6Available) ); } @@ -290,11 +297,35 @@ private void SetScreenshotData() } /// - /// Applies a detected gateway to a . + /// Detects the gateway of the local IP address and pings it, see . /// - private static void SetGatewayResult(ConnectionCheckItem item, IPAddress detected) + /// Item of the router check (IPv4 or IPv6). + /// Local IP address, or null. + /// The local IP address was detected via the route to the public IP address. + /// The gateway, or null if none was found. + private static async Task CheckGatewayAsync(ConnectionCheckItem item, IPAddress localIPAddress, + bool isRouted) { - item.Complete(detected?.ToString() ?? "-/-", detected != null ? ConnectionState.OK : ConnectionState.Critical); + var gateway = localIPAddress != null + ? await NetworkInterface.DetectGatewayFromLocalIPAddressAsync(localIPAddress) + : null; + + var isReachable = false; + + if (gateway != null) + { + var pingInfo = await PingProbe.PingAsync(gateway, GlobalStaticConfiguration.Dashboard_PingTimeout, + GlobalStaticConfiguration.Dashboard_PingAttempts, PingBuffer, CancellationToken.None); + + isReachable = pingInfo.Status == IPStatus.Success; + + Log.Debug($"{nameof(CheckGatewayAsync)} - Ping {gateway}: {pingInfo.Status}"); + } + + item.Complete(gateway?.ToString() ?? "-/-", + NetworkConnectionCheck.GetGatewayResult(gateway, isRouted, isReachable)); + + return gateway; } /// @@ -350,44 +381,32 @@ private Task CheckConnectionComputerDnsAsync(IPAddress localIPv4, IPAddress loca } /// - /// Checks the router connection asynchronously. + /// Checks the router connection asynchronously: detects the IPv4 / IPv6 gateway, pings both at the same time, then + /// resolves the DNS name. /// /// The already-detected local IPv4 address, or null. + /// The local IPv4 address was detected via the route to the public IP address. /// The already-detected local IPv6 address, or null if IPv6 is not available. /// A task representing the asynchronous operation. - private Task CheckConnectionRouterAsync(IPAddress localIPv4, IPAddress localIPv6) + private Task CheckConnectionRouterAsync(IPAddress localIPv4, bool isIPv4Routed, IPAddress localIPv6) { return Task.Run(async () => { Log.Debug($"{nameof(CheckConnectionRouterAsync)} - Checking router connection..."); - // Detect router IPv4 gateway - Log.Debug($"{nameof(CheckConnectionRouterAsync)} - Detecting router IPv4 address..."); - - var routerIPv4 = localIPv4 != null - ? await NetworkInterface.DetectGatewayFromLocalIPAddressAsync(localIPv4) - : null; - - SetGatewayResult(RouterIPv4, routerIPv4); - - // Detect router IPv6 gateway - IPAddress routerIPv6 = null; + var routerIPv4Task = CheckGatewayAsync(RouterIPv4, localIPv4, isIPv4Routed); + var routerIPv6Task = Task.FromResult(null); if (localIPv6 != null) - { - Log.Debug($"{nameof(CheckConnectionRouterAsync)} - Detecting router IPv6 address..."); - - routerIPv6 = await NetworkInterface.DetectGatewayFromLocalIPAddressAsync(localIPv6); - - SetGatewayResult(RouterIPv6, routerIPv6); - } + routerIPv6Task = CheckGatewayAsync(RouterIPv6, localIPv6, true); else - { SetIPv6NotAvailable(RouterIPv6); - } + + await Task.WhenAll(routerIPv4Task, routerIPv6Task); // Resolve router DNS - await ResolveDnsAsync(RouterDNS, routerIPv4, routerIPv6, nameof(CheckConnectionRouterAsync)); + await ResolveDnsAsync(RouterDNS, routerIPv4Task.Result, routerIPv6Task.Result, + nameof(CheckConnectionRouterAsync)); Log.Debug($"{nameof(CheckConnectionRouterAsync)} - Router connection check completed."); }); diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index bf9df0e672..d8c037f226 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -12,12 +12,12 @@ The **Dashboard** shows the status of your computer's current network connection ## Network connection -The **Network connection** widget (also shown in the status window) checks the connection of the computer, the gateway / router and the internet, each for IPv4, IPv6 and DNS. The icon in front of each value shows the result, hover over it to see the reason. **DNS** is the DNS name (PTR record) of the IPv4 address, or of the IPv6 address if the IPv4 address has none: +The **Network connection** widget (also shown in the status window) checks the connection of the computer, the gateway / router and the internet, each for IPv4, IPv6 and DNS. The gateway is pinged (2 attempts with a timeout of 2 seconds, like the IP Scanner). The icon in front of each value shows the result, hover over it to see the reason. **DNS** is the DNS name (PTR record) of the IPv4 address, or of the IPv6 address if the IPv4 address has none: | Icon | Meaning | |------|---------| | Green | OK | -| Yellow | Works partly or may not work, e.g. the computer has only a link-local IPv4 address (`169.254.x.x`, no address from a DHCP server) or no route to the internet (the address of the first active network adapter is shown) | +| Yellow | Works partly or may not work, e.g. the computer has only a link-local IPv4 address (`169.254.x.x`, no address from a DHCP server) or no route to the internet (the address of the first active network adapter is shown), the gateway did not reply to the ping (it may block ICMP), or the network adapter has no gateway (e.g. a VPN connection) | | Red | Failed, e.g. the computer has no IPv4 address or the DNS server did not answer | | Gray | Information, e.g. no IPv6 connection: the network or the internet provider may not support IPv6 (the IPv6 checks of the router and the internet are skipped), or no DNS name (PTR record) for the IP address, which many networks don't have | diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 341b5cb31c..1de819d2f8 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -55,6 +55,7 @@ Release date: **xx.xx.2026** - The network connection check is faster (also at startup and in the status window): the local IP address and the gateway are read directly from the network adapters instead of querying all adapter details incl. PowerShell up to four times per check. This also speeds up the detection of the local IP address in the **IP Scanner** when no route is available. [#PR](PRLINK) - The network connection shows a warning instead of OK if the computer has only a link-local IPv4 address (`169.254.x.x`, no address from a DHCP server) or no route to the internet. Without an IPv6 connection (e.g. the internet provider doesn't support IPv6), the IPv6 values are shown as information (gray) instead of failed (red), and the IPv6 address of the router and the internet are not checked. Hover over an icon to see the reason. [#PR](PRLINK) - The DNS name (PTR) of the IPv6 address is no longer requested after the DNS server failed for the IPv4 address (the same server would time out again), so the network connection check finishes faster without a working DNS server. Without an IP address to resolve, the DNS value is shown as information instead of failed. [#PR](PRLINK) +- The gateway / router is now pinged (2 attempts, 2 seconds timeout) instead of only checking that a gateway is configured. No reply is shown as a warning (some routers block ICMP). A network adapter without a gateway (e.g. a VPN connection) is shown as a warning instead of failed if the internet is routed via it. [#PR](PRLINK) ## Bug Fixes From e9472f6ec3d418a1ab75dc53b83862a934b11cf5 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:27:51 +0100 Subject: [PATCH 13/56] Fix: Dashboard: Validate the answer of the public IP address API (B5, R2) PublicIPAddressCheck.ParseResponse / FromException (Models) + tests (T2): success status code, plain address or first address of the family, private / link-local / loopback -> warning, DNS error of the API name. One CheckPublicIPAddressAsync for IPv4 and IPv6 (in parallel). Co-Authored-By: Claude Opus 5.5 --- .../Resources/Strings.Designer.cs | 27 ++++ .../Resources/Strings.resx | 9 ++ .../Network/ConnectionCheckReason.cs | 17 ++- .../Network/NetworkConnectionCheck.cs | 19 +++ .../Network/PublicIPAddressCheck.cs | 106 ++++++++++++++ .../Network/NetworkConnectionCheckTests.cs | 13 ++ .../Network/PublicIPAddressCheckTests.cs | 87 ++++++++++++ .../NetworkConnectionWidgetViewModel.cs | 131 ++++++++---------- Website/docs/application/dashboard.md | 2 +- Website/docs/changelog/next-release.md | 1 + 10 files changed, 333 insertions(+), 79 deletions(-) create mode 100644 Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs create mode 100644 Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs diff --git a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs index 23d378e452..bdb14ca9c1 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs +++ b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs @@ -2647,6 +2647,15 @@ public static string ConnectionCheckReason_IPv6NotAvailable { } } + /// + /// Looks up a localized string similar to The name of the public IP address API could not be resolved. Check the DNS server.. + /// + public static string ConnectionCheckReason_NameResolutionFailed { + get { + return ResourceManager.GetString("ConnectionCheckReason_NameResolutionFailed", resourceCulture); + } + } + /// /// Looks up a localized string similar to No default gateway found on the network adapter (e.g. a VPN connection without a gateway).. /// @@ -2692,6 +2701,24 @@ public static string ConnectionCheckReason_PTRNotFound { } } + /// + /// Looks up a localized string similar to The API returned a private IP address instead of the public one (e.g. the page of a hotspot / captive portal or a proxy).. + /// + public static string ConnectionCheckReason_PublicIPAddressPrivate { + get { + return ResourceManager.GetString("ConnectionCheckReason_PublicIPAddressPrivate", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The public IP address could not be requested from the API (no answer, an error or no IP address in the answer).. + /// + public static string ConnectionCheckReason_PublicIPAddressRequestFailed { + get { + return ResourceManager.GetString("ConnectionCheckReason_PublicIPAddressRequestFailed", resourceCulture); + } + } + /// /// Looks up a localized string similar to Connections. /// diff --git a/Source/NETworkManager.Localization/Resources/Strings.resx b/Source/NETworkManager.Localization/Resources/Strings.resx index 80a5b3e6ec..9e98f0fd34 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.resx @@ -5726,4 +5726,13 @@ Do you want to start the scan? The gateway did not reply to the ping. It may be offline or block ICMP. + + The API returned a private IP address instead of the public one (e.g. the page of a hotspot / captive portal or a proxy). + + + The public IP address could not be requested from the API (no answer, an error or no IP address in the answer). + + + The name of the public IP address API could not be resolved. Check the DNS server. + \ No newline at end of file diff --git a/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs b/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs index 084f8ceb27..4cc084b3e5 100644 --- a/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs +++ b/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs @@ -55,5 +55,20 @@ public enum ConnectionCheckReason /// /// The gateway did not reply to the ping (it may be offline or block ICMP). /// - GatewayNoReply + GatewayNoReply, + + /// + /// The API returned a private IP address (e.g. the page of a captive portal or a proxy). + /// + PublicIPAddressPrivate, + + /// + /// The public IP address could not be requested from the API (no answer, an error or no IP address). + /// + PublicIPAddressRequestFailed, + + /// + /// The host name of the public IP address API could not be resolved (DNS). + /// + NameResolutionFailed } diff --git a/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs b/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs index 38f698a7cc..71fd7ac3c7 100644 --- a/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs +++ b/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs @@ -102,4 +102,23 @@ public static ConnectionCheckResult GetGatewayResult(IPAddress gateway, bool isR ? new ConnectionCheckResult(ConnectionState.OK) : new ConnectionCheckResult(ConnectionState.Warning, ConnectionCheckReason.GatewayNoReply); } + + /// + /// State of the public IP address requested from the API: a public IP address is OK, a private one a warning + /// (e.g. captive portal or proxy), everything else critical. + /// + /// Result of the request. + /// State and reason. + public static ConnectionCheckResult GetPublicIPAddressResult(PublicIPAddressCheckResult result) + { + return result.Status switch + { + PublicIPAddressCheckStatus.Success => new ConnectionCheckResult(ConnectionState.OK), + PublicIPAddressCheckStatus.PrivateIPAddress => new ConnectionCheckResult(ConnectionState.Warning, + ConnectionCheckReason.PublicIPAddressPrivate), + PublicIPAddressCheckStatus.NameResolutionFailed => new ConnectionCheckResult(ConnectionState.Critical, + ConnectionCheckReason.NameResolutionFailed), + _ => new ConnectionCheckResult(ConnectionState.Critical, ConnectionCheckReason.PublicIPAddressRequestFailed) + }; + } } diff --git a/Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs b/Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs new file mode 100644 index 0000000000..4b59c0eb04 --- /dev/null +++ b/Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs @@ -0,0 +1,106 @@ +using System; +using System.Net; +using System.Net.Http; +using System.Net.Sockets; +using System.Text.RegularExpressions; +using NETworkManager.Utilities; + +namespace NETworkManager.Models.Network; + +/// +/// Status of the request of the public IP address from an API (e.g. api.ipify.org). +/// +public enum PublicIPAddressCheckStatus +{ + /// + /// The API returned a public IP address. + /// + Success, + + /// + /// The API returned a private, link-local or loopback IP address (e.g. the page of a captive portal or a proxy). + /// + PrivateIPAddress, + + /// + /// The API answered, but not with a success status code or without an IP address of the address family. + /// + InvalidResponse, + + /// + /// The host name of the API could not be resolved (DNS). + /// + NameResolutionFailed, + + /// + /// The request failed (e.g. no connection, timeout). + /// + RequestFailed +} + +/// +/// Result of the request of the public IP address. +/// +/// Status of the request. +/// IP address returned by the API (also if private), otherwise null. +public sealed record PublicIPAddressCheckResult(PublicIPAddressCheckStatus Status, IPAddress IPAddress = null); + +/// +/// Evaluates the answer of a public IP address API. +/// +public static class PublicIPAddressCheck +{ + /// + /// Parses the answer of the API. The answer should be the IP address as plain text; for custom APIs the first IP + /// address of the address family in the text is used (e.g. in a JSON object). + /// + /// The HTTP status code is 2xx. + /// Content of the answer. + /// IPv4 or IPv6. + /// Result of the request. + public static PublicIPAddressCheckResult ParseResponse(bool isSuccessStatusCode, string content, + AddressFamily addressFamily) + { + if (!isSuccessStatusCode) + return new PublicIPAddressCheckResult(PublicIPAddressCheckStatus.InvalidResponse); + + var text = content?.Trim() ?? string.Empty; + + if (!IPAddress.TryParse(text, out var ipAddress) || ipAddress.AddressFamily != addressFamily) + { + var match = addressFamily == AddressFamily.InterNetwork + ? RegexHelper.IPv4AddressExtractRegex().Match(text) + : Regex.Match(text, RegexHelper.IPv6AddressRegex); + + if (!match.Success || !IPAddress.TryParse(match.Value, out ipAddress) || + ipAddress.AddressFamily != addressFamily) + return new PublicIPAddressCheckResult(PublicIPAddressCheckStatus.InvalidResponse); + } + + var isPrivate = IPAddressHelper.IsPrivateIPAddress(ipAddress) || NetworkInterface.IsLinkLocal(ipAddress) || + IPAddress.IsLoopback(ipAddress); + + return new PublicIPAddressCheckResult( + isPrivate ? PublicIPAddressCheckStatus.PrivateIPAddress : PublicIPAddressCheckStatus.Success, ipAddress); + } + + /// + /// Result of a failed request: a DNS error (the host name of the API could not be resolved) or another error. + /// + /// Exception of the request. + /// Result of the request. + public static PublicIPAddressCheckResult FromException(Exception exception) + { + var isNameResolutionError = exception is HttpRequestException + { + InnerException: SocketException + { + SocketErrorCode: SocketError.HostNotFound or SocketError.NoData or SocketError.TryAgain + } + }; + + return new PublicIPAddressCheckResult(isNameResolutionError + ? PublicIPAddressCheckStatus.NameResolutionFailed + : PublicIPAddressCheckStatus.RequestFailed); + } +} diff --git a/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs index 57a381d337..ae3e1c08e3 100644 --- a/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs +++ b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs @@ -113,4 +113,17 @@ public void GetGatewayResult(string gateway, bool isRouted, bool isReachable, Co Assert.Equal(new ConnectionCheckResult(state, reason), NetworkConnectionCheck.GetGatewayResult(Ip(gateway), isRouted, isReachable)); } + + [Theory] + [InlineData(PublicIPAddressCheckStatus.Success, ConnectionState.OK, ConnectionCheckReason.None)] + [InlineData(PublicIPAddressCheckStatus.PrivateIPAddress, ConnectionState.Warning, ConnectionCheckReason.PublicIPAddressPrivate)] + [InlineData(PublicIPAddressCheckStatus.InvalidResponse, ConnectionState.Critical, ConnectionCheckReason.PublicIPAddressRequestFailed)] + [InlineData(PublicIPAddressCheckStatus.RequestFailed, ConnectionState.Critical, ConnectionCheckReason.PublicIPAddressRequestFailed)] + [InlineData(PublicIPAddressCheckStatus.NameResolutionFailed, ConnectionState.Critical, ConnectionCheckReason.NameResolutionFailed)] + public void GetPublicIPAddressResult(PublicIPAddressCheckStatus status, ConnectionState state, + ConnectionCheckReason reason) + { + Assert.Equal(new ConnectionCheckResult(state, reason), + NetworkConnectionCheck.GetPublicIPAddressResult(new PublicIPAddressCheckResult(status))); + } } diff --git a/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs b/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs new file mode 100644 index 0000000000..6aa7bc597b --- /dev/null +++ b/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs @@ -0,0 +1,87 @@ +using System; +using System.Threading.Tasks; +using System.Net; +using System.Net.Http; +using System.Net.Sockets; +using NETworkManager.Models.Network; +using Xunit; + +namespace NETworkManager.Tests.Network; + +public class PublicIPAddressCheckTests +{ + [Theory] + [InlineData("203.0.113.10", "203.0.113.10")] + [InlineData("203.0.113.10\n", "203.0.113.10")] + [InlineData(" 203.0.113.10 ", "203.0.113.10")] + // Custom API with the address in a text / JSON + [InlineData("{\"ip\":\"203.0.113.10\"}", "203.0.113.10")] + [InlineData("Your IP: 203.0.113.10", "203.0.113.10")] + public void ParseResponse_IPv4_Success(string content, string expected) + { + var result = PublicIPAddressCheck.ParseResponse(true, content, AddressFamily.InterNetwork); + + Assert.Equal(PublicIPAddressCheckStatus.Success, result.Status); + Assert.Equal(IPAddress.Parse(expected), result.IPAddress); + } + + [Theory] + [InlineData("2001:db8:1234::10")] + [InlineData("2001:db8:1234::10\n")] + public void ParseResponse_IPv6_Success(string content) + { + var result = PublicIPAddressCheck.ParseResponse(true, content, AddressFamily.InterNetworkV6); + + Assert.Equal(PublicIPAddressCheckStatus.Success, result.Status); + Assert.Equal(IPAddress.Parse("2001:db8:1234::10"), result.IPAddress); + } + + [Theory] + // e.g. the page of a captive portal or a proxy + [InlineData("Please sign in: http://192.168.1.1/login", AddressFamily.InterNetwork)] + [InlineData("10.1.0.1", AddressFamily.InterNetwork)] + [InlineData("169.254.1.1", AddressFamily.InterNetwork)] + [InlineData("127.0.0.1", AddressFamily.InterNetwork)] + [InlineData("fd00::1", AddressFamily.InterNetworkV6)] + public void ParseResponse_PrivateIPAddress(string content, AddressFamily addressFamily) + { + Assert.Equal(PublicIPAddressCheckStatus.PrivateIPAddress, + PublicIPAddressCheck.ParseResponse(true, content, addressFamily).Status); + } + + [Theory] + [InlineData(false, "203.0.113.10", AddressFamily.InterNetwork)] + [InlineData(true, "", AddressFamily.InterNetwork)] + [InlineData(true, null, AddressFamily.InterNetwork)] + [InlineData(true, "Forbidden", AddressFamily.InterNetwork)] + // Address of the other address family + [InlineData(true, "2001:db8::10", AddressFamily.InterNetwork)] + [InlineData(true, "203.0.113.10", AddressFamily.InterNetworkV6)] + public void ParseResponse_InvalidResponse(bool isSuccessStatusCode, string content, AddressFamily addressFamily) + { + var result = PublicIPAddressCheck.ParseResponse(isSuccessStatusCode, content, addressFamily); + + Assert.Equal(PublicIPAddressCheckStatus.InvalidResponse, result.Status); + Assert.Null(result.IPAddress); + } + + [Fact] + public void FromException_NameResolutionFailed() + { + var exception = new HttpRequestException("No such host is known.", + new SocketException((int)SocketError.HostNotFound)); + + Assert.Equal(PublicIPAddressCheckStatus.NameResolutionFailed, + PublicIPAddressCheck.FromException(exception).Status); + } + + [Fact] + public void FromException_RequestFailed() + { + Assert.Equal(PublicIPAddressCheckStatus.RequestFailed, + PublicIPAddressCheck.FromException(new HttpRequestException("Connection refused", + new SocketException((int)SocketError.ConnectionRefused))).Status); + Assert.Equal(PublicIPAddressCheckStatus.RequestFailed, + PublicIPAddressCheck.FromException(new TaskCanceledException("Timeout")).Status); + } +} diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index f93203ce3a..db31c41dfb 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -4,7 +4,6 @@ using System; using System.Net; using System.Net.Http; -using System.Text.RegularExpressions; using System.Threading; using System.Net.NetworkInformation; using System.Threading.Tasks; @@ -412,6 +411,50 @@ await ResolveDnsAsync(RouterDNS, routerIPv4Task.Result, routerIPv6Task.Result, }); } + /// + /// Requests the public IP address from the API (setting) and completes the item, see + /// . + /// + /// Item of the internet check (IPv4 or IPv6). + /// IPv4 or IPv6. + /// The IP address returned by the API (also if private), or null. + private static async Task CheckPublicIPAddressAsync(ConnectionCheckItem item, AddressFamily addressFamily) + { + var isIPv4 = addressFamily == AddressFamily.InterNetwork; + + var api = isIPv4 + ? SettingsManager.Current.Dashboard_UseCustomPublicIPv4AddressAPI + ? SettingsManager.Current.Dashboard_CustomPublicIPv4AddressAPI + : GlobalStaticConfiguration.Dashboard_PublicIPv4AddressAPI + : SettingsManager.Current.Dashboard_UseCustomPublicIPv6AddressAPI + ? SettingsManager.Current.Dashboard_CustomPublicIPv6AddressAPI + : GlobalStaticConfiguration.Dashboard_PublicIPv6AddressAPI; + + PublicIPAddressCheckResult result; + + try + { + Log.Debug($"{nameof(CheckPublicIPAddressAsync)} - Checking public {addressFamily} address from: {api}"); + + using var httpResponse = await PublicIPHttpClient.GetAsync(api); + var content = await httpResponse.Content.ReadAsStringAsync(); + + result = PublicIPAddressCheck.ParseResponse(httpResponse.IsSuccessStatusCode, content, addressFamily); + + Log.Debug($"{nameof(CheckPublicIPAddressAsync)} - HTTP {(int)httpResponse.StatusCode}: {result.Status} {result.IPAddress}"); + } + catch (Exception ex) + { + result = PublicIPAddressCheck.FromException(ex); + + Log.Debug($"{nameof(CheckPublicIPAddressAsync)} - {result.Status}: {ex.Message}"); + } + + item.Complete(result.IPAddress?.ToString() ?? "-/-", NetworkConnectionCheck.GetPublicIPAddressResult(result)); + + return result.IPAddress; + } + /// /// Checks the internet connection asynchronously. /// @@ -427,86 +470,20 @@ private Task CheckConnectionInternetAsync(bool isIPv6Available) Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Checking internet connection..."); - IPAddress publicIPv4 = null; - IPAddress publicIPv6 = null; + var publicIPv4Task = CheckPublicIPAddressAsync(InternetIPv4, AddressFamily.InterNetwork); + var publicIPv6Task = Task.FromResult(null); - // Detect public IPv4 and if it is reachable - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Detecting public IPv4 address..."); - - var publicIPv4AddressAPI = SettingsManager.Current.Dashboard_UseCustomPublicIPv4AddressAPI - ? SettingsManager.Current.Dashboard_CustomPublicIPv4AddressAPI - : GlobalStaticConfiguration.Dashboard_PublicIPv4AddressAPI; - - try - { - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Checking public IPv4 address from: " + publicIPv4AddressAPI); - - var httpResponse = await PublicIPHttpClient.GetAsync(publicIPv4AddressAPI); - var result = await httpResponse.Content.ReadAsStringAsync(); - var match = RegexHelper.IPv4AddressExtractRegex().Match(result); - - if (match.Success) - { - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv4 address detected: " + match.Value); - publicIPv4 = IPAddress.Parse(match.Value); - InternetIPv4.Complete(match.Value, ConnectionState.OK); - } - else - { - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv4 address not detected due to invalid format."); - InternetIPv4.Complete("-/-", ConnectionState.Critical); - } - } - catch (Exception ex) - { - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv4 address not detected due to exception: " + ex.Message); - - InternetIPv4.Complete("-/-", ConnectionState.Critical); - } - - // Detect public IPv6 and if it is reachable (only if the computer has a routed IPv6 address) - if (!isIPv6Available) - { - SetIPv6NotAvailable(InternetIPv6); - } + // Only if the computer has a routed IPv6 address + if (isIPv6Available) + publicIPv6Task = CheckPublicIPAddressAsync(InternetIPv6, AddressFamily.InterNetworkV6); else - { - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Detecting public IPv6 address..."); - - var publicIPv6AddressAPI = SettingsManager.Current.Dashboard_UseCustomPublicIPv6AddressAPI - ? SettingsManager.Current.Dashboard_CustomPublicIPv6AddressAPI - : GlobalStaticConfiguration.Dashboard_PublicIPv6AddressAPI; - - try - { - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Checking public IPv6 address from: " + publicIPv6AddressAPI); - - var httpResponse = await PublicIPHttpClient.GetAsync(publicIPv6AddressAPI); - var result = await httpResponse.Content.ReadAsStringAsync(); - var match = Regex.Match(result, RegexHelper.IPv6AddressRegex); - - if (match.Success) - { - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv6 address detected: " + match.Value); - publicIPv6 = IPAddress.Parse(match.Value); - InternetIPv6.Complete(match.Value, ConnectionState.OK); - } - else - { - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv6 address not detected due to invalid format."); - InternetIPv6.Complete("-/-", ConnectionState.Critical); - } - } - catch (Exception ex) - { - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Public IPv6 address not detected due to exception: " + ex.Message); - - InternetIPv6.Complete("-/-", ConnectionState.Critical); - } - } + SetIPv6NotAvailable(InternetIPv6); + + await Task.WhenAll(publicIPv4Task, publicIPv6Task); // Resolve internet DNS - await ResolveDnsAsync(InternetDNS, publicIPv4, publicIPv6, nameof(CheckConnectionInternetAsync)); + await ResolveDnsAsync(InternetDNS, publicIPv4Task.Result, publicIPv6Task.Result, + nameof(CheckConnectionInternetAsync)); Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Internet connection check completed."); }); diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index d8c037f226..4087ff2bd3 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -17,7 +17,7 @@ The **Network connection** widget (also shown in the status window) checks the c | Icon | Meaning | |------|---------| | Green | OK | -| Yellow | Works partly or may not work, e.g. the computer has only a link-local IPv4 address (`169.254.x.x`, no address from a DHCP server) or no route to the internet (the address of the first active network adapter is shown), the gateway did not reply to the ping (it may block ICMP), or the network adapter has no gateway (e.g. a VPN connection) | +| Yellow | Works partly or may not work, e.g. the computer has only a link-local IPv4 address (`169.254.x.x`, no address from a DHCP server) or no route to the internet (the address of the first active network adapter is shown), the gateway did not reply to the ping (it may block ICMP), the network adapter has no gateway (e.g. a VPN connection), or the public IP address API returned a private IP address (e.g. the page of a hotspot / captive portal or a proxy) | | Red | Failed, e.g. the computer has no IPv4 address or the DNS server did not answer | | Gray | Information, e.g. no IPv6 connection: the network or the internet provider may not support IPv6 (the IPv6 checks of the router and the internet are skipped), or no DNS name (PTR record) for the IP address, which many networks don't have | diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 1de819d2f8..e1c67f96ae 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -135,6 +135,7 @@ Release date: **xx.xx.2026** - Fixed the network connection widget (dashboard and status window) not updating when **Check public IP address** was changed in the settings until the application was restarted: an old public IP address could be shown as current. [#PR](PRLINK) - Fixed the network connection not being checked again when the network changed while the dashboard was open (e.g. a cable unplugged or a VPN connected), although the documentation says so. If the dashboard is not open, it is checked when it is opened again. [#PR](PRLINK) - Fixed the gateway / router not being found (shown as failed although the internet works) for VPN connections whose adapter is not an Ethernet or Wi-Fi adapter (e.g. the Windows VPN client with IKEv2 / SSTP). A VPN adapter without a gateway is no longer shown with the gateway `0.0.0.0`. [#PR](PRLINK) +- Fixed an IP address on an error page or the page of a hotspot / captive portal (e.g. hotel Wi-Fi) being shown as the public IP address. The answer of the API must have a success status code, a private IP address is shown as a warning, and an API name that can't be resolved points to the DNS server. The public IPv4 and IPv6 addresses are requested at the same time. [#PR](PRLINK) **Status window** From a4b0244f78f79101e280e9dfbf3f3cb019666b4c Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:30:10 +0100 Subject: [PATCH 14/56] Feature: Dashboard: Check the internet with ping, API and the Windows connectivity (I1, D1) Ping of the public IPv4 / IPv6 address settings (now as documented), public IP address API (if enabled) and NetworkInformation connectivity level (captive portal). NetworkConnectionCheck.GetInternetResult + tests. The internet card is always checked ("Check is disabled!" removed). D1: describe the public IP address settings (ping + route detection). Co-Authored-By: Claude Opus 5.5 --- .../Resources/Strings.Designer.cs | 40 +++++- .../Resources/Strings.resx | 16 ++- .../Network/ConnectionCheckReason.cs | 23 +++- .../Network/InternetConnectivity.cs | 74 +++++++++++ .../Network/NetworkConnectionCheck.cs | 39 ++++++ .../Network/NetworkConnectionCheckTests.cs | 41 ++++++ .../NetworkConnectionWidgetViewModel.cs | 117 ++++++++++++------ .../Views/NetworkConnectionWidgetView.xaml | 10 +- Website/docs/application/dashboard.md | 16 +-- Website/docs/changelog/next-release.md | 1 + 10 files changed, 320 insertions(+), 57 deletions(-) create mode 100644 Source/NETworkManager.Models/Network/InternetConnectivity.cs diff --git a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs index bdb14ca9c1..fea10981d4 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs +++ b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs @@ -2611,6 +2611,15 @@ public static string Connection { } } + /// + /// Looks up a localized string similar to Windows reports limited internet access (e.g. a hotspot / captive portal that requires a sign-in).. + /// + public static string ConnectionCheckReason_CaptivePortal { + get { + return ResourceManager.GetString("ConnectionCheckReason_CaptivePortal", resourceCulture); + } + } + /// /// Looks up a localized string similar to The DNS server did not answer or returned an error.. /// @@ -2629,6 +2638,24 @@ public static string ConnectionCheckReason_GatewayNoReply { } } + /// + /// Looks up a localized string similar to No reply to the ping and no public IP address from the API, but Windows reports internet access. ICMP and the API may be blocked by a firewall or only reachable via a proxy.. + /// + public static string ConnectionCheckReason_InternetAccessReportedByWindows { + get { + return ResourceManager.GetString("ConnectionCheckReason_InternetAccessReportedByWindows", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The internet is not reachable (no reply to the ping of the public IP address and no answer from the public IP address API).. + /// + public static string ConnectionCheckReason_InternetNotReachable { + get { + return ResourceManager.GetString("ConnectionCheckReason_InternetNotReachable", resourceCulture); + } + } + /// /// Looks up a localized string similar to Link-local address (169.254.x.x): the network adapter did not get an IPv4 address from a DHCP server.. /// @@ -2701,6 +2728,15 @@ public static string ConnectionCheckReason_PTRNotFound { } } + /// + /// Looks up a localized string similar to The public IP address is not requested (disabled in the settings).. + /// + public static string ConnectionCheckReason_PublicIPAddressCheckDisabled { + get { + return ResourceManager.GetString("ConnectionCheckReason_PublicIPAddressCheckDisabled", resourceCulture); + } + } + /// /// Looks up a localized string similar to The API returned a private IP address instead of the public one (e.g. the page of a hotspot / captive portal or a proxy).. /// @@ -6498,7 +6534,7 @@ public static string HelpMessage_ProfileHostPlaceholder { } /// - /// Looks up a localized string similar to Public IPv4 address reachable via ICMP.. + /// Looks up a localized string similar to Public IPv4 address that is pinged to check the internet connection. The route to it is used to detect the local IPv4 address (of the network adapter that is used for the internet).. /// public static string HelpMessage_PublicIPv4Address { get { @@ -6507,7 +6543,7 @@ public static string HelpMessage_PublicIPv4Address { } /// - /// Looks up a localized string similar to Public IPv6 address reachable via ICMP.. + /// Looks up a localized string similar to Public IPv6 address that is pinged to check the internet connection. The route to it is used to detect the local IPv6 address (of the network adapter that is used for the internet).. /// public static string HelpMessage_PublicIPv6Address { get { diff --git a/Source/NETworkManager.Localization/Resources/Strings.resx b/Source/NETworkManager.Localization/Resources/Strings.resx index 9e98f0fd34..970660330f 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.resx @@ -3091,10 +3091,10 @@ Enable profile file encryption in Settings>Profile to store credentials secur Enter a valid IPv6 address! - Public IPv4 address reachable via ICMP. + Public IPv4 address that is pinged to check the internet connection. The route to it is used to detect the local IPv4 address (of the network adapter that is used for the internet). - Public IPv6 address reachable via ICMP. + Public IPv6 address that is pinged to check the internet connection. The route to it is used to detect the local IPv6 address (of the network adapter that is used for the internet). Public IPv4 address @@ -5735,4 +5735,16 @@ Do you want to start the scan? The name of the public IP address API could not be resolved. Check the DNS server. + + Windows reports limited internet access (e.g. a hotspot / captive portal that requires a sign-in). + + + No reply to the ping and no public IP address from the API, but Windows reports internet access. ICMP and the API may be blocked by a firewall or only reachable via a proxy. + + + The internet is not reachable (no reply to the ping of the public IP address and no answer from the public IP address API). + + + The public IP address is not requested (disabled in the settings). + \ No newline at end of file diff --git a/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs b/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs index 4cc084b3e5..9b34c2f460 100644 --- a/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs +++ b/Source/NETworkManager.Models/Network/ConnectionCheckReason.cs @@ -70,5 +70,26 @@ public enum ConnectionCheckReason /// /// The host name of the public IP address API could not be resolved (DNS). /// - NameResolutionFailed + NameResolutionFailed, + + /// + /// Windows reports limited internet access (e.g. a hotspot / captive portal that requires a sign-in). + /// + CaptivePortal, + + /// + /// The ping and the public IP address API failed, but Windows reports internet access (e.g. ICMP and the API are + /// blocked by a firewall or only reachable via a proxy). + /// + InternetAccessReportedByWindows, + + /// + /// The internet is not reachable (no reply to the ping, no answer from the API). + /// + InternetNotReachable, + + /// + /// The public IP address is not requested (disabled in the settings). + /// + PublicIPAddressCheckDisabled } diff --git a/Source/NETworkManager.Models/Network/InternetConnectivity.cs b/Source/NETworkManager.Models/Network/InternetConnectivity.cs new file mode 100644 index 0000000000..a7872a15b3 --- /dev/null +++ b/Source/NETworkManager.Models/Network/InternetConnectivity.cs @@ -0,0 +1,74 @@ +using System; +using log4net; +using Windows.Networking.Connectivity; + +namespace NETworkManager.Models.Network; + +/// +/// Internet connectivity as reported by Windows (Network Connectivity Status Indicator, NCSI). Windows checks it +/// itself with its own test server, so no request is sent by the application. +/// +public enum InternetConnectivityLevel +{ + /// + /// Unknown (e.g. the status could not be read). + /// + Unknown, + + /// + /// No connection. + /// + None, + + /// + /// Local network access only. + /// + LocalAccess, + + /// + /// Limited internet access, e.g. a hotspot / captive portal that requires a sign-in. + /// + ConstrainedInternetAccess, + + /// + /// Internet access. + /// + InternetAccess +} + +/// +/// Reads the internet connectivity reported by Windows. +/// +public static class InternetConnectivity +{ + private static readonly ILog Log = LogManager.GetLogger(typeof(InternetConnectivity)); + + /// + /// Gets the internet connectivity of the connection profile that Windows uses for the internet. + /// + /// Connectivity level, on error. + public static InternetConnectivityLevel GetLevel() + { + try + { + var profile = NetworkInformation.GetInternetConnectionProfile(); + + if (profile == null) + return InternetConnectivityLevel.None; + + return profile.GetNetworkConnectivityLevel() switch + { + NetworkConnectivityLevel.None => InternetConnectivityLevel.None, + NetworkConnectivityLevel.LocalAccess => InternetConnectivityLevel.LocalAccess, + NetworkConnectivityLevel.ConstrainedInternetAccess => InternetConnectivityLevel.ConstrainedInternetAccess, + NetworkConnectivityLevel.InternetAccess => InternetConnectivityLevel.InternetAccess, + _ => InternetConnectivityLevel.Unknown + }; + } + catch (Exception ex) + { + Log.Warn("Could not get the internet connectivity reported by Windows.", ex); + return InternetConnectivityLevel.Unknown; + } + } +} diff --git a/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs b/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs index 71fd7ac3c7..b41765eeea 100644 --- a/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs +++ b/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs @@ -121,4 +121,43 @@ public static ConnectionCheckResult GetPublicIPAddressResult(PublicIPAddressChec _ => new ConnectionCheckResult(ConnectionState.Critical, ConnectionCheckReason.PublicIPAddressRequestFailed) }; } + + /// + /// State of the internet connection (IPv4 or IPv6) from three sources: the ping of the public IP address + /// (setting), the public IP address API (if enabled) and the connectivity reported by Windows. + /// + /// + /// A captive portal (Windows) is a warning. Otherwise a public IP address from the API or a reply to the ping is + /// OK; a private IP address from the API is a warning, as is a failed API when the ping works (e.g. the API is + /// blocked). If both fail but Windows reports internet access (only used for IPv4, Windows doesn't report it per + /// address family), ICMP and the API may be blocked: warning. Otherwise critical. + /// + /// IPv4 or IPv6. + /// The public IP address (setting) replied to the ping. + /// Result of the API, or null if disabled. + /// Internet connectivity reported by Windows. + /// State and reason. + public static ConnectionCheckResult GetInternetResult(AddressFamily addressFamily, bool isPingSuccessful, + PublicIPAddressCheckResult publicIPAddress, InternetConnectivityLevel connectivityLevel) + { + if (connectivityLevel == InternetConnectivityLevel.ConstrainedInternetAccess) + return new ConnectionCheckResult(ConnectionState.Warning, ConnectionCheckReason.CaptivePortal); + + if (publicIPAddress is { Status: PublicIPAddressCheckStatus.Success or PublicIPAddressCheckStatus.PrivateIPAddress }) + return GetPublicIPAddressResult(publicIPAddress); + + if (isPingSuccessful) + return publicIPAddress == null + ? new ConnectionCheckResult(ConnectionState.OK) + : new ConnectionCheckResult(ConnectionState.Warning, GetPublicIPAddressResult(publicIPAddress).Reason); + + if (addressFamily == AddressFamily.InterNetwork && + connectivityLevel == InternetConnectivityLevel.InternetAccess) + return new ConnectionCheckResult(ConnectionState.Warning, + ConnectionCheckReason.InternetAccessReportedByWindows); + + return publicIPAddress is { Status: PublicIPAddressCheckStatus.NameResolutionFailed } + ? new ConnectionCheckResult(ConnectionState.Critical, ConnectionCheckReason.NameResolutionFailed) + : new ConnectionCheckResult(ConnectionState.Critical, ConnectionCheckReason.InternetNotReachable); + } } diff --git a/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs index ae3e1c08e3..6606d6f4b1 100644 --- a/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs +++ b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs @@ -126,4 +126,45 @@ public void GetPublicIPAddressResult(PublicIPAddressCheckStatus status, Connecti Assert.Equal(new ConnectionCheckResult(state, reason), NetworkConnectionCheck.GetPublicIPAddressResult(new PublicIPAddressCheckResult(status))); } + + private static PublicIPAddressCheckResult Api(PublicIPAddressCheckStatus? status) => + status == null ? null : new PublicIPAddressCheckResult(status.Value); + + [Theory] + // API returned the public IP address + [InlineData(true, PublicIPAddressCheckStatus.Success, InternetConnectivityLevel.InternetAccess, ConnectionState.OK, ConnectionCheckReason.None)] + [InlineData(false, PublicIPAddressCheckStatus.Success, InternetConnectivityLevel.InternetAccess, ConnectionState.OK, ConnectionCheckReason.None)] + // API disabled: ping decides + [InlineData(true, null, InternetConnectivityLevel.InternetAccess, ConnectionState.OK, ConnectionCheckReason.None)] + [InlineData(false, null, InternetConnectivityLevel.LocalAccess, ConnectionState.Critical, ConnectionCheckReason.InternetNotReachable)] + // Captive portal (Windows) always wins + [InlineData(true, PublicIPAddressCheckStatus.Success, InternetConnectivityLevel.ConstrainedInternetAccess, ConnectionState.Warning, ConnectionCheckReason.CaptivePortal)] + [InlineData(false, null, InternetConnectivityLevel.ConstrainedInternetAccess, ConnectionState.Warning, ConnectionCheckReason.CaptivePortal)] + // Private IP address from the API (e.g. proxy) + [InlineData(true, PublicIPAddressCheckStatus.PrivateIPAddress, InternetConnectivityLevel.InternetAccess, ConnectionState.Warning, ConnectionCheckReason.PublicIPAddressPrivate)] + // Ping works, API blocked / DNS broken + [InlineData(true, PublicIPAddressCheckStatus.RequestFailed, InternetConnectivityLevel.InternetAccess, ConnectionState.Warning, ConnectionCheckReason.PublicIPAddressRequestFailed)] + [InlineData(true, PublicIPAddressCheckStatus.NameResolutionFailed, InternetConnectivityLevel.InternetAccess, ConnectionState.Warning, ConnectionCheckReason.NameResolutionFailed)] + // Ping and API failed, but Windows reports internet access (ICMP and API blocked, e.g. proxy) + [InlineData(false, PublicIPAddressCheckStatus.RequestFailed, InternetConnectivityLevel.InternetAccess, ConnectionState.Warning, ConnectionCheckReason.InternetAccessReportedByWindows)] + [InlineData(false, null, InternetConnectivityLevel.InternetAccess, ConnectionState.Warning, ConnectionCheckReason.InternetAccessReportedByWindows)] + // Everything failed + [InlineData(false, PublicIPAddressCheckStatus.RequestFailed, InternetConnectivityLevel.LocalAccess, ConnectionState.Critical, ConnectionCheckReason.InternetNotReachable)] + [InlineData(false, PublicIPAddressCheckStatus.InvalidResponse, InternetConnectivityLevel.Unknown, ConnectionState.Critical, ConnectionCheckReason.InternetNotReachable)] + [InlineData(false, PublicIPAddressCheckStatus.NameResolutionFailed, InternetConnectivityLevel.None, ConnectionState.Critical, ConnectionCheckReason.NameResolutionFailed)] + public void GetInternetResult_IPv4(bool isPingSuccessful, PublicIPAddressCheckStatus? apiStatus, + InternetConnectivityLevel level, ConnectionState state, ConnectionCheckReason reason) + { + Assert.Equal(new ConnectionCheckResult(state, reason), + NetworkConnectionCheck.GetInternetResult(AddressFamily.InterNetwork, isPingSuccessful, Api(apiStatus), level)); + } + + [Fact] + public void GetInternetResult_IPv6_WindowsInternetAccessIsNotUsed() + { + // Windows doesn't report the connectivity per address family (internet access may be IPv4 only) + Assert.Equal(new ConnectionCheckResult(ConnectionState.Critical, ConnectionCheckReason.InternetNotReachable), + NetworkConnectionCheck.GetInternetResult(AddressFamily.InterNetworkV6, false, + Api(PublicIPAddressCheckStatus.RequestFailed), InternetConnectivityLevel.InternetAccess)); + } } diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index db31c41dfb..481138fde7 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -218,9 +218,7 @@ await Task.WhenAll( } /// - /// Resets all connection check items to their initial "checking" state. The Internet items are - /// only reset when the public IP address check is enabled, so they stay untouched (not stuck - /// "checking") when it is disabled. + /// Resets all connection check items to their initial "checking" state. /// private void ResetAllItems() { @@ -232,9 +230,6 @@ private void ResetAllItems() RouterIPv6.Reset(); RouterDNS.Reset(); - if (!SettingsManager.Current.Dashboard_CheckPublicIPAddress) - return; - InternetIPv4.Reset(); InternetIPv6.Reset(); InternetDNS.Reset(); @@ -253,9 +248,6 @@ private void SetScreenshotData() RouterIPv6.Complete(ScreenshotData.RouterIPv6, ConnectionState.OK); RouterDNS.Complete(ScreenshotData.RouterDNS, ConnectionState.OK); - if (!SettingsManager.Current.Dashboard_CheckPublicIPAddress) - return; - InternetIPv4.Complete(ScreenshotData.InternetIPv4, ConnectionState.OK); InternetIPv6.Complete(ScreenshotData.InternetIPv6, ConnectionState.OK); InternetDNS.Complete(ScreenshotData.InternetDNS, ConnectionState.OK); @@ -412,17 +404,13 @@ await ResolveDnsAsync(RouterDNS, routerIPv4Task.Result, routerIPv6Task.Result, } /// - /// Requests the public IP address from the API (setting) and completes the item, see - /// . + /// Requests the public IP address from the API (setting), see . /// - /// Item of the internet check (IPv4 or IPv6). /// IPv4 or IPv6. - /// The IP address returned by the API (also if private), or null. - private static async Task CheckPublicIPAddressAsync(ConnectionCheckItem item, AddressFamily addressFamily) + /// Result of the request. + private static async Task RequestPublicIPAddressAsync(AddressFamily addressFamily) { - var isIPv4 = addressFamily == AddressFamily.InterNetwork; - - var api = isIPv4 + var api = addressFamily == AddressFamily.InterNetwork ? SettingsManager.Current.Dashboard_UseCustomPublicIPv4AddressAPI ? SettingsManager.Current.Dashboard_CustomPublicIPv4AddressAPI : GlobalStaticConfiguration.Dashboard_PublicIPv4AddressAPI @@ -430,29 +418,84 @@ private static async Task CheckPublicIPAddressAsync(ConnectionCheckIt ? SettingsManager.Current.Dashboard_CustomPublicIPv6AddressAPI : GlobalStaticConfiguration.Dashboard_PublicIPv6AddressAPI; - PublicIPAddressCheckResult result; - try { - Log.Debug($"{nameof(CheckPublicIPAddressAsync)} - Checking public {addressFamily} address from: {api}"); + Log.Debug($"{nameof(RequestPublicIPAddressAsync)} - Checking public {addressFamily} address from: {api}"); using var httpResponse = await PublicIPHttpClient.GetAsync(api); var content = await httpResponse.Content.ReadAsStringAsync(); - result = PublicIPAddressCheck.ParseResponse(httpResponse.IsSuccessStatusCode, content, addressFamily); + var result = PublicIPAddressCheck.ParseResponse(httpResponse.IsSuccessStatusCode, content, addressFamily); - Log.Debug($"{nameof(CheckPublicIPAddressAsync)} - HTTP {(int)httpResponse.StatusCode}: {result.Status} {result.IPAddress}"); + Log.Debug($"{nameof(RequestPublicIPAddressAsync)} - HTTP {(int)httpResponse.StatusCode}: {result.Status} {result.IPAddress}"); + + return result; } catch (Exception ex) { - result = PublicIPAddressCheck.FromException(ex); + var result = PublicIPAddressCheck.FromException(ex); + + Log.Debug($"{nameof(RequestPublicIPAddressAsync)} - {result.Status}: {ex.Message}"); - Log.Debug($"{nameof(CheckPublicIPAddressAsync)} - {result.Status}: {ex.Message}"); + return result; } + } + + /// + /// Pings the public IP address (setting) to check if the internet is reachable. + /// + /// Public IPv4 or IPv6 address (setting). + /// IPv4 or IPv6. + /// Result of the ping, or null if the address in the settings is invalid. + private static async Task PingPublicIPAddressAsync(string ipAddress, AddressFamily addressFamily) + { + if (!IPAddress.TryParse(ipAddress, out var target) || target.AddressFamily != addressFamily) + { + Log.Warn($"{nameof(PingPublicIPAddressAsync)} - Invalid public {addressFamily} address \"{ipAddress}\" in the settings, skipping the ping."); + return null; + } + + var pingInfo = await PingProbe.PingAsync(target, GlobalStaticConfiguration.Dashboard_PingTimeout, + GlobalStaticConfiguration.Dashboard_PingAttempts, PingBuffer, CancellationToken.None); - item.Complete(result.IPAddress?.ToString() ?? "-/-", NetworkConnectionCheck.GetPublicIPAddressResult(result)); + Log.Debug($"{nameof(PingPublicIPAddressAsync)} - Ping {target}: {pingInfo.Status}"); - return result.IPAddress; + return pingInfo; + } + + /// + /// Checks the internet connection of an address family: ping of the public IP address (setting) and the public IP + /// address API (if enabled) at the same time, see . + /// + /// Item of the internet check (IPv4 or IPv6). + /// IPv4 or IPv6. + /// Internet connectivity reported by Windows (read once per check). + /// The IP address returned by the API (also if private), or null. + private static async Task CheckInternetAsync(ConnectionCheckItem item, AddressFamily addressFamily, + Task connectivityLevelTask) + { + var pingTask = PingPublicIPAddressAsync(addressFamily == AddressFamily.InterNetwork + ? SettingsManager.Current.Dashboard_PublicIPv4Address + : SettingsManager.Current.Dashboard_PublicIPv6Address, addressFamily); + + var publicIPAddressTask = SettingsManager.Current.Dashboard_CheckPublicIPAddress + ? RequestPublicIPAddressAsync(addressFamily) + : Task.FromResult(null); + + await Task.WhenAll(pingTask, publicIPAddressTask, connectivityLevelTask); + + var pingInfo = pingTask.Result; + var publicIPAddress = publicIPAddressTask.Result; + var isPingSuccessful = pingInfo is { Status: IPStatus.Success }; + + // Public IP address (API), otherwise the pinged address with the round-trip time + var value = publicIPAddress?.IPAddress?.ToString() ?? + (isPingSuccessful ? $"{pingInfo.IPAddress} ({pingInfo.Time} ms)" : "-/-"); + + item.Complete(value, NetworkConnectionCheck.GetInternetResult(addressFamily, isPingSuccessful, + publicIPAddress, connectivityLevelTask.Result)); + + return publicIPAddress?.IPAddress; } /// @@ -464,26 +507,30 @@ private Task CheckConnectionInternetAsync(bool isIPv6Available) { return Task.Run(async () => { - // If public IP address check is disabled - if (!SettingsManager.Current.Dashboard_CheckPublicIPAddress) - return; - Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Checking internet connection..."); - var publicIPv4Task = CheckPublicIPAddressAsync(InternetIPv4, AddressFamily.InterNetwork); + var connectivityLevelTask = Task.Run(InternetConnectivity.GetLevel); + + var publicIPv4Task = CheckInternetAsync(InternetIPv4, AddressFamily.InterNetwork, connectivityLevelTask); var publicIPv6Task = Task.FromResult(null); // Only if the computer has a routed IPv6 address if (isIPv6Available) - publicIPv6Task = CheckPublicIPAddressAsync(InternetIPv6, AddressFamily.InterNetworkV6); + publicIPv6Task = CheckInternetAsync(InternetIPv6, AddressFamily.InterNetworkV6, connectivityLevelTask); else SetIPv6NotAvailable(InternetIPv6); await Task.WhenAll(publicIPv4Task, publicIPv6Task); - // Resolve internet DNS - await ResolveDnsAsync(InternetDNS, publicIPv4Task.Result, publicIPv6Task.Result, - nameof(CheckConnectionInternetAsync)); + Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Windows reports: {connectivityLevelTask.Result}"); + + // Resolve internet DNS (of the public IP address) + if (SettingsManager.Current.Dashboard_CheckPublicIPAddress) + await ResolveDnsAsync(InternetDNS, publicIPv4Task.Result, publicIPv6Task.Result, + nameof(CheckConnectionInternetAsync)); + else + InternetDNS.Complete("-/-", new ConnectionCheckResult(ConnectionState.Info, + ConnectionCheckReason.PublicIPAddressCheckDisabled)); Log.Debug($"{nameof(CheckConnectionInternetAsync)} - Internet connection check completed."); }); diff --git a/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml b/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml index 9c950b98a6..5a450dabcf 100644 --- a/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml +++ b/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml @@ -8,7 +8,6 @@ xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:viewModels="clr-namespace:NETworkManager.ViewModels" - xmlns:settings="clr-namespace:NETworkManager.Settings;assembly=NETworkManager.Settings" xmlns:wpfHelpers="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF" mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:NetworkConnectionWidgetViewModel}"> @@ -17,7 +16,6 @@ - @@ -42,7 +43,108 @@ + Text="{Binding Value, Mode=OneWay}"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index da2077ea36..5a26ecbf69 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -58,6 +58,7 @@ Release date: **xx.xx.2026** - The gateway / router is now pinged (2 attempts, 2 seconds timeout) instead of only checking that a gateway is configured. No reply is shown as a warning (some routers block ICMP). A network adapter without a gateway (e.g. a VPN connection) is shown as a warning instead of failed if the internet is routed via it. [#PR](PRLINK) - The internet is now checked with a ping of the public IPv4 / IPv6 address (settings, `1.1.1.1` / `2606:4700:4700::1111`), the public IP address API and the internet connectivity reported by Windows. A hotspot / captive portal that requires a sign-in, a blocked public IP address API (e.g. a proxy) or blocked ICMP are shown as a warning instead of the internet being not reachable. With **Check public IP address** disabled, the internet is still checked (ping and Windows) instead of showing "Check is disabled!". [#PR](PRLINK) - The values of the network connection (dashboard and status window) can be opened in other tools via the context menu: Port Scanner, Ping Monitor, Traceroute and DNS Lookup, the gateway / router also in the Web Console, the public IP address also in RDAP and IP Geolocation. **Copy** copies the whole value. Opening a tool from the status window shows the main window. [#PR](PRLINK) +- A value of the network connection that is cut off in a narrow window (e.g. a long IPv6 address or DNS name) is shown completely in the tooltip. [#PR](PRLINK) ## Bug Fixes From e157adad8c8414beb980b964b9c96d882423d66d Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:34:06 +0100 Subject: [PATCH 17/56] Feature: Dashboard: Show the time of the last network connection check (M4) RefreshStatusControl in the header of the internet card. Co-Authored-By: Claude Opus 5.5 --- .../NetworkConnectionWidgetViewModel.cs | 18 ++++++++++++++++++ .../Views/NetworkConnectionWidgetView.xaml | 6 ++++++ Website/docs/changelog/next-release.md | 1 + 3 files changed, 25 insertions(+) diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index 66594f27bd..fb0c1a958a 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -93,6 +93,22 @@ public class NetworkConnectionWidgetViewModel : ViewModelBase #endregion + /// + /// Gets the time of the last check, null before the first one. + /// + public DateTime? LastCheckTime + { + get; + private set + { + if (value == field) + return; + + field = value; + OnPropertyChanged(); + } + } + /// /// Gets or sets a value indicating whether a check is currently running. /// @@ -161,6 +177,8 @@ private async Task CheckAsync() // spammed - the checks run at the same time await TaskHelper.WithMinimumDurationAsync(RunTask, GlobalStaticConfiguration.ApplicationUIRefreshInterval); + LastCheckTime = DateTime.Now; + Log.Info("Network connection check completed."); } while (_recheckPending); } diff --git a/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml b/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml index 002b9f0c1c..3b61f4a09d 100644 --- a/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml +++ b/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml @@ -8,6 +8,7 @@ xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:viewModels="clr-namespace:NETworkManager.ViewModels" + xmlns:internalControls="clr-namespace:NETworkManager.Controls" xmlns:models="clr-namespace:NETworkManager.Models;assembly=NETworkManager.Models" xmlns:wpfHelpers="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF" mc:Ignorable="d" @@ -251,6 +252,11 @@ + public ICommand CheckCommand => new RelayCommand(_ => Check(), _ => !IsChecking); + /// + /// Gets the command to copy all values (with the reasons of the states), e.g. for a support request. + /// + public ICommand CopyAllCommand => new RelayCommand(_ => CopyAllAction(), _ => !IsChecking && LastCheckTime != null); + + private void CopyAllAction() + { + var text = new StringBuilder(); + + foreach (var (title, ipv4, ipv6, dns) in new[] + { + (Strings.Computer, ComputerIPv4, ComputerIPv6, ComputerDNS), + (Strings.GatewayRouter, RouterIPv4, RouterIPv6, RouterDNS), + (Strings.Internet, InternetIPv4, InternetIPv6, InternetDNS) + }) + { + if (text.Length > 0) + text.AppendLine(); + + text.AppendLine(title); + + foreach (var (label, item) in new[] { (Strings.IPv4, ipv4), (Strings.IPv6, ipv6), (Strings.DNS, dns) }) + text.AppendLine(item.Message == null + ? $"{label}: {item.Value}" + : $"{label}: {item.Value} ({item.Message})"); + } + + ClipboardHelper.SetClipboard(text.ToString().TrimEnd()); + } + #endregion #region Methods diff --git a/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml b/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml index 3b61f4a09d..c9fd70a08f 100644 --- a/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml +++ b/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml @@ -257,27 +257,50 @@ IsRefreshing="{Binding IsChecking}" HorizontalAlignment="Right" Margin="10,0,10,0" /> - + + + + Date: Wed, 25 Nov 2026 21:36:23 +0100 Subject: [PATCH 19/56] Feature: Dashboard: Option to hide widgets (H1-H4) Settings Dashboard_Show*Widget (default true), "Widgets" section on the dashboard settings page. The dashboard is a StackPanel (no gaps for hidden widgets); widget views are created when shown the first time; the remaining IP API widget spans the row; empty state if all are hidden. The network connection is only checked if its widget is shown. Co-Authored-By: Claude Opus 5.5 --- .../Resources/Strings.Designer.cs | 18 +++++ .../Resources/Strings.resx | 6 ++ .../GlobalStaticConfiguration.cs | 4 + .../NETworkManager.Settings/SettingsInfo.cs | 52 ++++++++++++ .../ViewModels/DashboardSettingsViewModel.cs | 80 +++++++++++++++++++ .../Views/DashboardSettingsView.xaml | 11 ++- .../NETworkManager/Views/DashboardView.xaml | 49 ++++++------ .../Views/DashboardView.xaml.cs | 80 ++++++++++++++++--- Website/docs/application/dashboard.md | 8 ++ Website/docs/changelog/next-release.md | 4 + 10 files changed, 276 insertions(+), 36 deletions(-) diff --git a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs index 63e7e8f154..9b9bce0063 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs +++ b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs @@ -1005,6 +1005,15 @@ public static string AllSettingsCanBeChangedLaterInTheSettings { } } + /// + /// Looks up a localized string similar to All widgets are hidden. You can show them in the settings of the dashboard.. + /// + public static string AllWidgetsAreHiddenMessage { + get { + return ResourceManager.GetString("AllWidgetsAreHiddenMessage", resourceCulture); + } + } + /// /// Looks up a localized string similar to Always show icon in tray. /// @@ -16286,6 +16295,15 @@ public static string WideSubnet { } } + /// + /// Looks up a localized string similar to Widgets. + /// + public static string Widgets { + get { + return ResourceManager.GetString("Widgets", resourceCulture); + } + } + /// /// Looks up a localized string similar to Width. /// diff --git a/Source/NETworkManager.Localization/Resources/Strings.resx b/Source/NETworkManager.Localization/Resources/Strings.resx index c96510342f..ab386840d8 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.resx @@ -5750,4 +5750,10 @@ Do you want to start the scan? Copy all + + Widgets + + + All widgets are hidden. You can show them in the settings of the dashboard. + \ No newline at end of file diff --git a/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs b/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs index aadcb15f83..e309bf3711 100644 --- a/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs +++ b/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs @@ -139,6 +139,10 @@ public static class GlobalStaticConfiguration public static string Dashboard_PublicIPv6AddressAPI => "https://api6.ipify.org"; public static bool Dashboard_CheckIPApiIPGeolocation => false; public static bool Dashboard_CheckIPApiDNSResolver => false; + public static bool Dashboard_ShowNetworkConnectionWidget => true; + public static bool Dashboard_ShowSpeedTestWidget => true; + public static bool Dashboard_ShowIPGeolocationWidget => true; + public static bool Dashboard_ShowDNSResolverWidget => true; /// /// Minimum time between two network connection checks when switching back to the dashboard (the public IP address diff --git a/Source/NETworkManager.Settings/SettingsInfo.cs b/Source/NETworkManager.Settings/SettingsInfo.cs index 9e8eca8dc2..db63590ddc 100644 --- a/Source/NETworkManager.Settings/SettingsInfo.cs +++ b/Source/NETworkManager.Settings/SettingsInfo.cs @@ -1063,6 +1063,58 @@ public bool Dashboard_CheckIPApiDNSResolver } } = GlobalStaticConfiguration.Dashboard_CheckIPApiDNSResolver; + public bool Dashboard_ShowNetworkConnectionWidget + { + get; + set + { + if (value == field) + return; + + field = value; + OnPropertyChanged(); + } + } = GlobalStaticConfiguration.Dashboard_ShowNetworkConnectionWidget; + + public bool Dashboard_ShowSpeedTestWidget + { + get; + set + { + if (value == field) + return; + + field = value; + OnPropertyChanged(); + } + } = GlobalStaticConfiguration.Dashboard_ShowSpeedTestWidget; + + public bool Dashboard_ShowIPGeolocationWidget + { + get; + set + { + if (value == field) + return; + + field = value; + OnPropertyChanged(); + } + } = GlobalStaticConfiguration.Dashboard_ShowIPGeolocationWidget; + + public bool Dashboard_ShowDNSResolverWidget + { + get; + set + { + if (value == field) + return; + + field = value; + OnPropertyChanged(); + } + } = GlobalStaticConfiguration.Dashboard_ShowDNSResolverWidget; + #endregion #region Network Interface diff --git a/Source/NETworkManager/ViewModels/DashboardSettingsViewModel.cs b/Source/NETworkManager/ViewModels/DashboardSettingsViewModel.cs index 5d843accac..d5aa014d4b 100644 --- a/Source/NETworkManager/ViewModels/DashboardSettingsViewModel.cs +++ b/Source/NETworkManager/ViewModels/DashboardSettingsViewModel.cs @@ -185,6 +185,82 @@ public bool CheckIPApiDNSResolverEnabled } } + /// + /// Gets or sets a value indicating whether the network connection widget is shown on the dashboard. + /// + public bool ShowNetworkConnectionWidget + { + get; + set + { + if (value == field) + return; + + if (!_isLoading) + SettingsManager.Current.Dashboard_ShowNetworkConnectionWidget = value; + + field = value; + OnPropertyChanged(); + } + } + + /// + /// Gets or sets a value indicating whether the speed test widget is shown on the dashboard. + /// + public bool ShowSpeedTestWidget + { + get; + set + { + if (value == field) + return; + + if (!_isLoading) + SettingsManager.Current.Dashboard_ShowSpeedTestWidget = value; + + field = value; + OnPropertyChanged(); + } + } + + /// + /// Gets or sets a value indicating whether the IP geolocation widget is shown on the dashboard. + /// + public bool ShowIPGeolocationWidget + { + get; + set + { + if (value == field) + return; + + if (!_isLoading) + SettingsManager.Current.Dashboard_ShowIPGeolocationWidget = value; + + field = value; + OnPropertyChanged(); + } + } + + /// + /// Gets or sets a value indicating whether the DNS resolver widget is shown on the dashboard. + /// + public bool ShowDNSResolverWidget + { + get; + set + { + if (value == field) + return; + + if (!_isLoading) + SettingsManager.Current.Dashboard_ShowDNSResolverWidget = value; + + field = value; + OnPropertyChanged(); + } + } + #endregion #region Contructor, load settings @@ -215,6 +291,10 @@ private void LoadSettings() CustomPublicIPv6AddressAPI = SettingsManager.Current.Dashboard_CustomPublicIPv6AddressAPI; CheckIPApiIPGeolocationEnabled = SettingsManager.Current.Dashboard_CheckIPApiIPGeolocation; CheckIPApiDNSResolverEnabled = SettingsManager.Current.Dashboard_CheckIPApiDNSResolver; + ShowNetworkConnectionWidget = SettingsManager.Current.Dashboard_ShowNetworkConnectionWidget; + ShowSpeedTestWidget = SettingsManager.Current.Dashboard_ShowSpeedTestWidget; + ShowIPGeolocationWidget = SettingsManager.Current.Dashboard_ShowIPGeolocationWidget; + ShowDNSResolverWidget = SettingsManager.Current.Dashboard_ShowDNSResolverWidget; } #endregion diff --git a/Source/NETworkManager/Views/DashboardSettingsView.xaml b/Source/NETworkManager/Views/DashboardSettingsView.xaml index 467652114d..bde05ddeb6 100644 --- a/Source/NETworkManager/Views/DashboardSettingsView.xaml +++ b/Source/NETworkManager/Views/DashboardSettingsView.xaml @@ -156,7 +156,7 @@ - + + + + + + \ No newline at end of file diff --git a/Source/NETworkManager/Views/DashboardView.xaml b/Source/NETworkManager/Views/DashboardView.xaml index b4d0f0a276..56efa62b03 100644 --- a/Source/NETworkManager/Views/DashboardView.xaml +++ b/Source/NETworkManager/Views/DashboardView.xaml @@ -5,36 +5,33 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:viewModels="clr-namespace:NETworkManager.ViewModels" + xmlns:icons="clr-namespace:NETworkManager.Controls;assembly=NETworkManager.Controls" mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:DashboardViewModel}"> - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/Source/NETworkManager/Views/DashboardView.xaml.cs b/Source/NETworkManager/Views/DashboardView.xaml.cs index 116e92de9a..a570cf5e63 100644 --- a/Source/NETworkManager/Views/DashboardView.xaml.cs +++ b/Source/NETworkManager/Views/DashboardView.xaml.cs @@ -1,5 +1,7 @@ using System; using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; using NETworkManager.Settings; using NETworkManager.ViewModels; @@ -9,10 +11,11 @@ public partial class DashboardView { private readonly DashboardViewModel _viewModel = new(); - private readonly NetworkConnectionWidgetView _networkConnectionWidgetView = new(); - private readonly IPApiIPGeolocationWidgetView _ipApiIPGeolocationWidgetView = new(); - private readonly IPApiDNSResolverWidgetView _ipApiDNSResolverWidgetView = new(); - private readonly SpeedTestWidgetView _speedTestWidgetView = new(); + // Widgets are created when they are shown the first time (e.g. a hidden IP API widget sends no request) + private NetworkConnectionWidgetView _networkConnectionWidgetView; + private IPApiIPGeolocationWidgetView _ipApiIPGeolocationWidgetView; + private IPApiDNSResolverWidgetView _ipApiDNSResolverWidgetView; + private SpeedTestWidgetView _speedTestWidgetView; /// /// The dashboard is the selected application (see / ). @@ -34,11 +37,8 @@ public DashboardView() InitializeComponent(); DataContext = _viewModel; - // Load views - ContentControlNetworkConnection.Content = _networkConnectionWidgetView; - ContentControlIPApiIPGeolocation.Content = _ipApiIPGeolocationWidgetView; - ContentControlIPApiDNSResolver.Content = _ipApiDNSResolverWidgetView; - ContentControlSpeedTest.Content = _speedTestWidgetView; + // Show the widgets + ApplyWidgetSettings(); // The settings are changed while the dashboard is hidden (settings view) - check again when it is shown SettingsManager.Current.PropertyChanged += SettingsManager_PropertyChanged; @@ -53,6 +53,9 @@ public void OnViewVisible() _viewModel.OnViewVisible(); + // The widgets may have been shown or hidden in the settings + ApplyWidgetSettings(); + // Check the network connection again if something changed, or if the last check is older than the recheck // interval (e.g. the public IP address may have changed) - not on every switch between the applications if (_isOutdated || DateTime.Now - _lastCheck >= GlobalStaticConfiguration.Dashboard_RecheckInterval) @@ -79,12 +82,71 @@ public void OnNetworkChanged() private void CheckNetworkConnection() { + // Hidden: checked when it is shown (a changed setting marks the data as outdated) + if (!SettingsManager.Current.Dashboard_ShowNetworkConnectionWidget) + return; + _isOutdated = false; _lastCheck = DateTime.Now; _networkConnectionWidgetView.Check(); } + /// + /// Shows / hides the widgets (settings Dashboard_Show*Widget) and creates them when they are shown the + /// first time. + /// + private void ApplyWidgetSettings() + { + var settings = SettingsManager.Current; + + _networkConnectionWidgetView = ShowWidget(ContentControlNetworkConnection, + settings.Dashboard_ShowNetworkConnectionWidget, _networkConnectionWidgetView); + _speedTestWidgetView = ShowWidget(ContentControlSpeedTest, settings.Dashboard_ShowSpeedTestWidget, + _speedTestWidgetView); + _ipApiIPGeolocationWidgetView = ShowWidget(ContentControlIPApiIPGeolocation, + settings.Dashboard_ShowIPGeolocationWidget, _ipApiIPGeolocationWidgetView); + _ipApiDNSResolverWidgetView = ShowWidget(ContentControlIPApiDNSResolver, + settings.Dashboard_ShowDNSResolverWidget, _ipApiDNSResolverWidgetView); + + // IP geolocation (2/3) and DNS resolver (1/3) in one row, the remaining one spans the row + var showIPGeolocation = settings.Dashboard_ShowIPGeolocationWidget; + var showDNSResolver = settings.Dashboard_ShowDNSResolverWidget; + + GridIPApi.Visibility = showIPGeolocation || showDNSResolver ? Visibility.Visible : Visibility.Collapsed; + + Grid.SetColumnSpan(ContentControlIPApiIPGeolocation, showDNSResolver ? 3 : 5); + Grid.SetColumn(ContentControlIPApiDNSResolver, showIPGeolocation ? 4 : 0); + Grid.SetColumnSpan(ContentControlIPApiDNSResolver, showIPGeolocation ? 1 : 5); + + EmptyStateMessageNoWidgets.Visibility = settings.Dashboard_ShowNetworkConnectionWidget || + settings.Dashboard_ShowSpeedTestWidget || showIPGeolocation || + showDNSResolver + ? Visibility.Collapsed + : Visibility.Visible; + } + + /// + /// Shows or hides a widget. The view of the widget is created when it is shown the first time. + /// + /// Content control of the widget. + /// Show the widget. + /// View of the widget, null if not created yet. + /// Type of the view. + /// View of the widget, null if it was never shown. + private static T ShowWidget(ContentControl contentControl, bool show, T view) where T : UserControl, new() + { + contentControl.Visibility = show ? Visibility.Visible : Visibility.Collapsed; + + if (!show || view != null) + return view; + + view = new T(); + contentControl.Content = view; + + return view; + } + private void SettingsManager_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName?.StartsWith("Dashboard_", StringComparison.Ordinal) == true) diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index 6d29c05f0c..a7cfa320d2 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -113,6 +113,14 @@ Enables or disables the detection of the DNS resolver in use via [`ip-api.com`]( **Default:** `Enabled` +### Widgets + +Show or hide the widgets on the dashboard: **Network connection**, **Speed Test**, **IP geolocation** and **DNS resolver**. A hidden widget doesn't check anything (e.g. no request is sent to `ip-api.com`). If one of IP geolocation and DNS resolver is hidden, the other one uses the whole width. The status window always shows the network connection. + +**Type:** `Boolean` + +**Default:** `Enabled` (all widgets) + ## Speed Test The **Speed Test** widget measures the current connection's download and upload speed, latency, and jitter against [`speed.cloudflare.com`](https://speed.cloudflare.com/). The test is **user-initiated** — it does not run automatically on dashboard load. Click **Speed Test** to run a measurement. diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 9dde5600dd..e2c4cece28 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -29,6 +29,10 @@ Release date: **xx.xx.2026** - Added a dedicated browser for services advertised on the local network, including printers, scanners, web servers and media devices. Select an interface and service types or service type profiles (e.g. Printers, editable in the settings, with history) or discover all types, inspect hostnames, ports, IPv4 / IPv6 addresses and TXT records, filter, copy and export the results. **Raw DNS records** shows the individual DNS records instead, with each TXT entry on its own row; other and unknown record types are preserved as raw data. Includes the `mdns` / `dnssd` run commands (e.g. `mdns printers 30`) with suggestions of the service type profiles and durations. Thanks to [@MovGP0](https://github.com/MovGP0) [#3719](https://github.com/BornToBeRoot/NETworkManager/pull/3719) +**Dashboard** + +- The widgets of the dashboard (Network connection, Speed Test, IP geolocation, DNS resolver) can be hidden in the settings (**Settings > Dashboard > Widgets**). A hidden widget doesn't check anything. [#PR](PRLINK) + ## Improvements **Network Interface** From 5171cbc21f936fc7afa3e31b35f9a991f098692b Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:36:35 +0100 Subject: [PATCH 20/56] Docs: Dashboard: F5 only refreshes the network connection widget (D3) Co-Authored-By: Claude Opus 5.5 --- Website/docs/application/dashboard.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index a7cfa320d2..3ee4c03f78 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -27,11 +27,11 @@ Right-click a value to open it in another tool: an IP address in the **Port Scan | Key | Action | |-----|--------| -| `F5` | Refresh the dashboard | +| `F5` | Check the network connection again | :::note -You may need to click into a widget first before keyboard shortcuts are recognized. +`F5` only works while the **Network connection** widget has the focus (e.g. click into it first). The other widgets are refreshed with their refresh button. ::: From 4702f0608f49d2c6bd6c367f85994e2c940806a0 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:36:35 +0100 Subject: [PATCH 21/56] Docs: Dashboard: Check IP geolocation / DNS resolver are disabled by default (D4) Co-Authored-By: Claude Opus 5.5 --- Website/docs/application/dashboard.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index 3ee4c03f78..2816abe11c 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -103,7 +103,7 @@ The free API endpoint is limited to 45 requests per minute, supports only the `h **Type:** `Boolean` -**Default:** `Enabled` +**Default:** `Disabled` ### Check DNS resolver @@ -111,7 +111,7 @@ Enables or disables the detection of the DNS resolver in use via [`ip-api.com`]( **Type:** `Boolean` -**Default:** `Enabled` +**Default:** `Disabled` ### Widgets From 70022f6877ee6f2f2b86e45e43dfd39f1f3aae0e Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:37:15 +0100 Subject: [PATCH 22/56] Fix: Dashboard: No rows left loading after an unexpected error in the check (B1) Follow-up of B1: an exception (e.g. of the ping) ended the check, the remaining rows kept the loading indicator until the next check. Co-Authored-By: Claude Opus 5.5 --- .../NetworkConnectionWidgetViewModel.cs | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index 5c40017ead..58ff57e015 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -2,6 +2,7 @@ using NETworkManager.Settings; using NETworkManager.Utilities; using System; +using System.Linq; using System.Net; using System.Net.Http; using System.Threading; @@ -217,6 +218,10 @@ private async Task CheckAsync() catch (Exception ex) { Log.Error("Network connection check failed.", ex); + + // Don't leave the remaining rows loading until the next check + foreach (var item in GetAllItems().Where(x => x.IsChecking)) + item.Complete("-/-", ConnectionState.Critical); } finally { @@ -238,9 +243,7 @@ private async Task RunTask() return; } - // Detect the local IPv4/IPv6 address once and share it between the Computer and Router - // checks below, instead of each of them redetecting it independently (both used to - // trigger their own, potentially PowerShell-backed, network interface lookup). + // Detect the local IPv4/IPv6 address once and share it between the Computer, Router and Internet checks below var localIPv4Task = DetectLocalIPAddressAsync(SettingsManager.Current.Dashboard_PublicIPv4Address, AddressFamily.InterNetwork); var localIPv6Task = DetectLocalIPAddressAsync(SettingsManager.Current.Dashboard_PublicIPv6Address, @@ -272,17 +275,20 @@ await Task.WhenAll( /// private void ResetAllItems() { - ComputerIPv4.Reset(); - ComputerIPv6.Reset(); - ComputerDNS.Reset(); - - RouterIPv4.Reset(); - RouterIPv6.Reset(); - RouterDNS.Reset(); + foreach (var item in GetAllItems()) + item.Reset(); + } - InternetIPv4.Reset(); - InternetIPv6.Reset(); - InternetDNS.Reset(); + /// + /// Gets all connection check items. + /// + private ConnectionCheckItem[] GetAllItems() + { + return + [ + ComputerIPv4, ComputerIPv6, ComputerDNS, RouterIPv4, RouterIPv6, RouterDNS, InternetIPv4, InternetIPv6, + InternetDNS + ]; } /// From 8c774614662b30b5560df8a6bf1313726152c1d9 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:56:04 +0100 Subject: [PATCH 23/56] Fix: Dashboard: Center the "all widgets hidden" message, gap only between visible widgets (H3) The scroll viewer keeps its margin of 10 on all sides (as before), the gap of 10 is set between the visible widgets only. Co-Authored-By: Claude Opus 5.5 --- .../NETworkManager/Views/DashboardView.xaml | 49 ++++++++++--------- .../Views/DashboardView.xaml.cs | 16 ++++-- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/Source/NETworkManager/Views/DashboardView.xaml b/Source/NETworkManager/Views/DashboardView.xaml index 56efa62b03..02b35e8d64 100644 --- a/Source/NETworkManager/Views/DashboardView.xaml +++ b/Source/NETworkManager/Views/DashboardView.xaml @@ -10,29 +10,32 @@ d:DataContext="{d:DesignInstance viewModels:DashboardViewModel}"> - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/NETworkManager/Views/DashboardView.xaml.cs b/Source/NETworkManager/Views/DashboardView.xaml.cs index a570cf5e63..8fb5b0e4a1 100644 --- a/Source/NETworkManager/Views/DashboardView.xaml.cs +++ b/Source/NETworkManager/Views/DashboardView.xaml.cs @@ -1,5 +1,6 @@ using System; using System.ComponentModel; +using System.Linq; using System.Windows; using System.Windows.Controls; using NETworkManager.Settings; @@ -119,11 +120,16 @@ private void ApplyWidgetSettings() Grid.SetColumn(ContentControlIPApiDNSResolver, showIPGeolocation ? 4 : 0); Grid.SetColumnSpan(ContentControlIPApiDNSResolver, showIPGeolocation ? 1 : 5); - EmptyStateMessageNoWidgets.Visibility = settings.Dashboard_ShowNetworkConnectionWidget || - settings.Dashboard_ShowSpeedTestWidget || showIPGeolocation || - showDNSResolver - ? Visibility.Collapsed - : Visibility.Visible; + // Gap of 10 between the visible widgets (not below the last one, the scroll viewer has a margin of 10) + var visibleWidgets = new FrameworkElement[] + { ContentControlNetworkConnection, ContentControlSpeedTest, GridIPApi } + .Where(x => x.Visibility == Visibility.Visible) + .ToList(); + + for (var i = 0; i < visibleWidgets.Count; i++) + visibleWidgets[i].Margin = new Thickness(0, 0, 0, i < visibleWidgets.Count - 1 ? 10 : 0); + + EmptyStateMessageNoWidgets.Visibility = visibleWidgets.Count == 0 ? Visibility.Visible : Visibility.Collapsed; } /// From 43e32cf8a8489b2139ec9937476425121ae5af0b Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:56:23 +0100 Subject: [PATCH 24/56] Docs: Dashboard: Help of Check public IP address describes the check without the API (I1) Co-Authored-By: Claude Opus 5.5 --- .../NETworkManager.Localization/Resources/Strings.Designer.cs | 4 +++- Source/NETworkManager.Localization/Resources/Strings.resx | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs index 9b9bce0063..d1d68dc8f1 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs +++ b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs @@ -6354,7 +6354,9 @@ public static string HelpMessage_CheckIPGeolocation { /// /// Looks up a localized string similar to The public IP address is determined via ipify.org. /// - ///URL: https://api.ipify.org and https://api6.ipify.org. + ///URL: https://api.ipify.org and https://api6.ipify.org + /// + ///If disabled, the internet connection is only checked with a ping of the public IP address and the internet connectivity reported by Windows.. /// public static string HelpMessage_CheckPublicIPAddress { get { diff --git a/Source/NETworkManager.Localization/Resources/Strings.resx b/Source/NETworkManager.Localization/Resources/Strings.resx index ab386840d8..44b7039584 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.resx @@ -2092,7 +2092,9 @@ URL: https://api.github.com/ The public IP address is determined via ipify.org. -URL: https://api.ipify.org and https://api6.ipify.org +URL: https://api.ipify.org and https://api6.ipify.org + +If disabled, the internet connection is only checked with a ping of the public IP address and the internet connectivity reported by Windows. Privacy From 5c31f5a2f9bca715c2eb4e3e536115d1b8d8f323 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:56:23 +0100 Subject: [PATCH 25/56] Docs: Status window: Opens when the network has settled, no focus (S1, S2) Co-Authored-By: Claude Opus 5.5 --- Website/docs/settings/status.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Website/docs/settings/status.md b/Website/docs/settings/status.md index 019dbae397..61b6202cc5 100644 --- a/Website/docs/settings/status.md +++ b/Website/docs/settings/status.md @@ -8,7 +8,7 @@ keywords: [NETworkManager, status settings, status window, network change notifi ### Show status window on network change -Show the status window when the network changes (e.g. Ethernet cable is plugged in, WLAN or VPN is connected, etc.). +Show the status window when the network changes (e.g. Ethernet cable is plugged in, WLAN or VPN is connected, etc.). The window opens once the network has settled (5 seconds without further changes, e.g. after the DHCP address was assigned) and checks the network connection, see [Dashboard](../application/dashboard.md#network-connection). It doesn't take the keyboard focus; click into it to keep it open. **Type:** `Boolean` From 6b2e14b0d08d25fa0c5917e28e837ecff826b89e Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:03:33 +0100 Subject: [PATCH 26/56] Fix: Dashboard: Accept only a real public IP address from the API (CR1) IPAddress.TryParse accepted e.g. "429" (HTTP status code) as 0.0.1.173: only dotted-quad IPv4 / IPv6 without scope id. Unspecified, multicast and reserved addresses are an invalid answer, carrier-grade NAT (100.64/10) is private. PublicIPAddressCheck.GetStatus + tests. Co-Authored-By: Claude Opus 5.5 --- .../Network/PublicIPAddressCheck.cs | 66 +++++++++++++++++-- .../Network/PublicIPAddressCheckTests.cs | 38 +++++++++++ 2 files changed, 97 insertions(+), 7 deletions(-) diff --git a/Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs b/Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs index 4b59c0eb04..a98fa1812a 100644 --- a/Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs +++ b/Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs @@ -66,22 +66,74 @@ public static PublicIPAddressCheckResult ParseResponse(bool isSuccessStatusCode, var text = content?.Trim() ?? string.Empty; - if (!IPAddress.TryParse(text, out var ipAddress) || ipAddress.AddressFamily != addressFamily) + if (!TryParseIPAddress(text, addressFamily, out var ipAddress)) { var match = addressFamily == AddressFamily.InterNetwork ? RegexHelper.IPv4AddressExtractRegex().Match(text) : Regex.Match(text, RegexHelper.IPv6AddressRegex); - if (!match.Success || !IPAddress.TryParse(match.Value, out ipAddress) || - ipAddress.AddressFamily != addressFamily) + if (!match.Success || !TryParseIPAddress(match.Value, addressFamily, out ipAddress)) return new PublicIPAddressCheckResult(PublicIPAddressCheckStatus.InvalidResponse); } - var isPrivate = IPAddressHelper.IsPrivateIPAddress(ipAddress) || NetworkInterface.IsLinkLocal(ipAddress) || - IPAddress.IsLoopback(ipAddress); + return GetStatus(ipAddress) switch + { + PublicIPAddressCheckStatus.InvalidResponse => new PublicIPAddressCheckResult( + PublicIPAddressCheckStatus.InvalidResponse), + var status => new PublicIPAddressCheckResult(status, ipAddress) + }; + } + + /// + /// Parses an IP address in its normal notation only: IPv4 as four decimal numbers ( + /// also accepts e.g. "429" as 0.0.1.173 - an HTTP status code in the answer), IPv6 without a scope id. + /// + /// Text to parse. + /// IPv4 or IPv6. + /// Parsed IP address. + /// if the text is an IP address of the address family. + private static bool TryParseIPAddress(string text, AddressFamily addressFamily, out IPAddress ipAddress) + { + ipAddress = null; + + var isValidNotation = addressFamily == AddressFamily.InterNetwork + ? RegexHelper.IPv4AddressRegex().IsMatch(text) + : text.Contains(':') && !text.Contains('%'); + + return isValidNotation && IPAddress.TryParse(text, out ipAddress) && ipAddress.AddressFamily == addressFamily; + } + + /// + /// Status of an IP address returned by the API: a private, shared (carrier-grade NAT), link-local or loopback + /// address is not the public IP address (e.g. the answer of a captive portal or a proxy); an unspecified, + /// multicast or reserved address is no valid answer. + /// + /// IP address returned by the API. + /// , + /// or . + public static PublicIPAddressCheckStatus GetStatus(IPAddress ipAddress) + { + var bytes = ipAddress.GetAddressBytes(); + + if (ipAddress.AddressFamily == AddressFamily.InterNetwork) + { + // 0.0.0.0/8 (this network), 224.0.0.0/4 (multicast), 240.0.0.0/4 (reserved, broadcast) + if (bytes[0] == 0 || bytes[0] >= 224) + return PublicIPAddressCheckStatus.InvalidResponse; + + // 100.64.0.0/10 (shared address space, carrier-grade NAT) + if (bytes[0] == 100 && bytes[1] is >= 64 and <= 127) + return PublicIPAddressCheckStatus.PrivateIPAddress; + } + else if (ipAddress.Equals(IPAddress.IPv6Any) || ipAddress.IsIPv6Multicast) + { + return PublicIPAddressCheckStatus.InvalidResponse; + } - return new PublicIPAddressCheckResult( - isPrivate ? PublicIPAddressCheckStatus.PrivateIPAddress : PublicIPAddressCheckStatus.Success, ipAddress); + return IPAddressHelper.IsPrivateIPAddress(ipAddress) || NetworkInterface.IsLinkLocal(ipAddress) || + IPAddress.IsLoopback(ipAddress) + ? PublicIPAddressCheckStatus.PrivateIPAddress + : PublicIPAddressCheckStatus.Success; } /// diff --git a/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs b/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs index 6aa7bc597b..edc2b06f73 100644 --- a/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs +++ b/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs @@ -65,6 +65,44 @@ public void ParseResponse_InvalidResponse(bool isSuccessStatusCode, string conte Assert.Null(result.IPAddress); } + [Theory] + // IPAddress.TryParse accepts these as IPv4 (e.g. an HTTP status code as answer) + [InlineData("429", AddressFamily.InterNetwork)] + [InlineData("1", AddressFamily.InterNetwork)] + [InlineData("10.1", AddressFamily.InterNetwork)] + [InlineData("0x7f000001", AddressFamily.InterNetwork)] + // Unspecified, multicast, reserved / broadcast + [InlineData("0.0.0.0", AddressFamily.InterNetwork)] + [InlineData("224.0.0.1", AddressFamily.InterNetwork)] + [InlineData("255.255.255.255", AddressFamily.InterNetwork)] + [InlineData("::", AddressFamily.InterNetworkV6)] + [InlineData("ff02::1", AddressFamily.InterNetworkV6)] + // Scope id + [InlineData("fe80::1%12", AddressFamily.InterNetworkV6)] + public void ParseResponse_NotAnIPAddressOrReserved_InvalidResponse(string content, AddressFamily addressFamily) + { + var result = PublicIPAddressCheck.ParseResponse(true, content, addressFamily); + + Assert.Equal(PublicIPAddressCheckStatus.InvalidResponse, result.Status); + Assert.Null(result.IPAddress); + } + + [Theory] + [InlineData("203.0.113.10", PublicIPAddressCheckStatus.Success)] + [InlineData("2001:db8::10", PublicIPAddressCheckStatus.Success)] + [InlineData("100.64.0.1", PublicIPAddressCheckStatus.PrivateIPAddress)] + [InlineData("100.127.255.254", PublicIPAddressCheckStatus.PrivateIPAddress)] + [InlineData("100.128.0.1", PublicIPAddressCheckStatus.Success)] + [InlineData("172.16.0.1", PublicIPAddressCheckStatus.PrivateIPAddress)] + [InlineData("::1", PublicIPAddressCheckStatus.PrivateIPAddress)] + [InlineData("fe80::1", PublicIPAddressCheckStatus.PrivateIPAddress)] + [InlineData("0.1.2.3", PublicIPAddressCheckStatus.InvalidResponse)] + [InlineData("240.0.0.1", PublicIPAddressCheckStatus.InvalidResponse)] + public void GetStatus(string ipAddress, PublicIPAddressCheckStatus expected) + { + Assert.Equal(expected, PublicIPAddressCheck.GetStatus(IPAddress.Parse(ipAddress))); + } + [Fact] public void FromException_NameResolutionFailed() { From fd3497b4b97150512eb179a34722e8dcb6d6dc5e Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:04:18 +0100 Subject: [PATCH 27/56] Fix: Dashboard: Public IP address only from plain text or a JSON value (CR2, CR3) The first IPv4-looking text anywhere in the answer was used (e.g. a link to the login server on a captive portal page); IPv6 in JSON never matched (the regex needs whitespace around the address). Now: the whole answer, or the first JSON string value that is an address of the family. Tests. Co-Authored-By: Claude Opus 5.5 --- .../Resources/Strings.Designer.cs | 4 +- .../Resources/Strings.resx | 4 +- .../Network/PublicIPAddressCheck.cs | 48 ++++++++++++++----- .../Network/PublicIPAddressCheckTests.cs | 15 ++++-- Website/docs/application/dashboard.md | 4 +- Website/docs/changelog/next-release.md | 1 + 6 files changed, 54 insertions(+), 22 deletions(-) diff --git a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs index d1d68dc8f1..66834eb7fe 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs +++ b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs @@ -6392,7 +6392,7 @@ public static string HelpMessage_CustomCommandFilePath { } /// - /// Looks up a localized string similar to URL to a web service that can be reached via http or https and returns an IPv4 address e.g., "xx.xx.xx.xx" as response.. + /// Looks up a localized string similar to URL to a web service that can be reached via http or https and returns an IPv4 address e.g., "xx.xx.xx.xx" as response (plain text, or a JSON object with the address as a string value).. /// public static string HelpMessage_CustomPublicIPv4AddressAPI { get { @@ -6401,7 +6401,7 @@ public static string HelpMessage_CustomPublicIPv4AddressAPI { } /// - /// Looks up a localized string similar to URL to a web service that can be reached via http or https and returns an IPv6 address e.g., "xxxx:xx:xxx::xx" as response.. + /// Looks up a localized string similar to URL to a web service that can be reached via http or https and returns an IPv6 address e.g., "xxxx:xx:xxx::xx" as response (plain text, or a JSON object with the address as a string value).. /// public static string HelpMessage_CustomPublicIPv6AddressAPI { get { diff --git a/Source/NETworkManager.Localization/Resources/Strings.resx b/Source/NETworkManager.Localization/Resources/Strings.resx index 44b7039584..632c9159d6 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.resx @@ -2185,7 +2185,7 @@ is disabled! Use custom IPv4 address API - URL to a web service that can be reached via http or https and returns an IPv4 address e.g., "xx.xx.xx.xx" as response. + URL to a web service that can be reached via http or https and returns an IPv4 address e.g., "xx.xx.xx.xx" as response (plain text, or a JSON object with the address as a string value). Could not parse public ip address from "{0}"! Try another service or use the default... @@ -3327,7 +3327,7 @@ If the option is disabled again, the values are no longer modified. However, the SNTP server(s) - URL to a web service that can be reached via http or https and returns an IPv6 address e.g., "xxxx:xx:xxx::xx" as response. + URL to a web service that can be reached via http or https and returns an IPv6 address e.g., "xxxx:xx:xxx::xx" as response (plain text, or a JSON object with the address as a string value). IP endpoint diff --git a/Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs b/Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs index a98fa1812a..267746cada 100644 --- a/Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs +++ b/Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs @@ -48,11 +48,12 @@ public sealed record PublicIPAddressCheckResult(PublicIPAddressCheckStatus Statu /// /// Evaluates the answer of a public IP address API. /// -public static class PublicIPAddressCheck +public static partial class PublicIPAddressCheck { /// - /// Parses the answer of the API. The answer should be the IP address as plain text; for custom APIs the first IP - /// address of the address family in the text is used (e.g. in a JSON object). + /// Parses the answer of the API: the IP address as plain text, or (custom APIs) the first string value of a JSON + /// object that is an IP address of the address family (e.g. {"ip":"203.0.113.10"}). Other text (e.g. the + /// HTML page of a captive portal with a link to an IP address) is no valid answer. /// /// The HTTP status code is 2xx. /// Content of the answer. @@ -66,15 +67,9 @@ public static PublicIPAddressCheckResult ParseResponse(bool isSuccessStatusCode, var text = content?.Trim() ?? string.Empty; - if (!TryParseIPAddress(text, addressFamily, out var ipAddress)) - { - var match = addressFamily == AddressFamily.InterNetwork - ? RegexHelper.IPv4AddressExtractRegex().Match(text) - : Regex.Match(text, RegexHelper.IPv6AddressRegex); - - if (!match.Success || !TryParseIPAddress(match.Value, addressFamily, out ipAddress)) - return new PublicIPAddressCheckResult(PublicIPAddressCheckStatus.InvalidResponse); - } + if (!TryParseIPAddress(text, addressFamily, out var ipAddress) && + !TryParseJsonStringValue(text, addressFamily, out ipAddress)) + return new PublicIPAddressCheckResult(PublicIPAddressCheckStatus.InvalidResponse); return GetStatus(ipAddress) switch { @@ -84,6 +79,35 @@ public static PublicIPAddressCheckResult ParseResponse(bool isSuccessStatusCode, }; } + /// + /// Gets the first string value of a JSON object ("...") that is an IP address of the address family. + /// + /// Answer of the API. + /// IPv4 or IPv6. + /// Parsed IP address. + /// if an IP address was found. + private static bool TryParseJsonStringValue(string text, AddressFamily addressFamily, out IPAddress ipAddress) + { + ipAddress = null; + + if (!text.StartsWith('{')) + return false; + + foreach (Match match in JsonStringRegex().Matches(text)) + { + if (TryParseIPAddress(match.Groups[1].Value, addressFamily, out ipAddress)) + return true; + } + + return false; + } + + /// + /// A short JSON string without whitespace, e.g. "203.0.113.10" (the value without the quotes in group 1). + /// + [GeneratedRegex("\"([^\"\\s]{2,45})\"")] + private static partial Regex JsonStringRegex(); + /// /// Parses an IP address in its normal notation only: IPv4 as four decimal numbers ( /// also accepts e.g. "429" as 0.0.1.173 - an HTTP status code in the answer), IPv6 without a scope id. diff --git a/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs b/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs index edc2b06f73..96a8a9540d 100644 --- a/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs +++ b/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs @@ -14,9 +14,9 @@ public class PublicIPAddressCheckTests [InlineData("203.0.113.10", "203.0.113.10")] [InlineData("203.0.113.10\n", "203.0.113.10")] [InlineData(" 203.0.113.10 ", "203.0.113.10")] - // Custom API with the address in a text / JSON + // Custom API with the address in a JSON object [InlineData("{\"ip\":\"203.0.113.10\"}", "203.0.113.10")] - [InlineData("Your IP: 203.0.113.10", "203.0.113.10")] + [InlineData("{ \"country\": \"DE\", \"ip\": \"203.0.113.10\" }", "203.0.113.10")] public void ParseResponse_IPv4_Success(string content, string expected) { var result = PublicIPAddressCheck.ParseResponse(true, content, AddressFamily.InterNetwork); @@ -28,6 +28,7 @@ public void ParseResponse_IPv4_Success(string content, string expected) [Theory] [InlineData("2001:db8:1234::10")] [InlineData("2001:db8:1234::10\n")] + [InlineData("{\"ip\":\"2001:db8:1234::10\"}")] public void ParseResponse_IPv6_Success(string content) { var result = PublicIPAddressCheck.ParseResponse(true, content, AddressFamily.InterNetworkV6); @@ -37,9 +38,9 @@ public void ParseResponse_IPv6_Success(string content) } [Theory] - // e.g. the page of a captive portal or a proxy - [InlineData("Please sign in: http://192.168.1.1/login", AddressFamily.InterNetwork)] + // e.g. the answer of a captive portal or a proxy [InlineData("10.1.0.1", AddressFamily.InterNetwork)] + [InlineData("{\"ip\":\"192.168.1.1\"}", AddressFamily.InterNetwork)] [InlineData("169.254.1.1", AddressFamily.InterNetwork)] [InlineData("127.0.0.1", AddressFamily.InterNetwork)] [InlineData("fd00::1", AddressFamily.InterNetworkV6)] @@ -54,6 +55,12 @@ public void ParseResponse_PrivateIPAddress(string content, AddressFamily address [InlineData(true, "", AddressFamily.InterNetwork)] [InlineData(true, null, AddressFamily.InterNetwork)] [InlineData(true, "Forbidden", AddressFamily.InterNetwork)] + // HTML page of a captive portal with a link to its (public) login server + [InlineData(true, "Sign in", AddressFamily.InterNetwork)] + [InlineData(true, "Sign in: http://192.168.1.1/login", AddressFamily.InterNetwork)] + [InlineData(true, "Your IP: 203.0.113.10", AddressFamily.InterNetwork)] + // JSON without an address of the family + [InlineData(true, "{\"ip\":\"2001:db8::10\"}", AddressFamily.InterNetwork)] // Address of the other address family [InlineData(true, "2001:db8::10", AddressFamily.InterNetwork)] [InlineData(true, "203.0.113.10", AddressFamily.InterNetworkV6)] diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index 2816abe11c..15ef7a5aff 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -67,7 +67,7 @@ Enables or disables the resolution of the public IP address via [`api.ipify.org` ### Use custom IPv4 address API -Override the default IPv4 address API to resolve the public IP address. The API should return only a plain text IPv4 address like `xx.xx.xx.xx`. +Override the default IPv4 address API to resolve the public IP address. The API should return only a plain text IPv4 address like `xx.xx.xx.xx`, or a JSON object with the address as a string value like `{"ip":"xx.xx.xx.xx"}`. Other answers (e.g. an HTML page) are not accepted. **Type:** `Boolean | String` @@ -81,7 +81,7 @@ Override the default IPv4 address API to resolve the public IP address. The API ### Use custom IPv6 address API -Override the default IPv6 address API to resolve the public IP address. The API should return only a plain text IPv6 address like `xxxx:xx:xxx::xx`. +Override the default IPv6 address API to resolve the public IP address. The API should return only a plain text IPv6 address like `xxxx:xx:xxx::xx`, or a JSON object with the address as a string value like `{"ip":"xxxx:xx:xxx::xx"}`. Other answers (e.g. an HTML page) are not accepted. **Type:** `Boolean | String` diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index e2c4cece28..85c4dd97bf 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -145,6 +145,7 @@ Release date: **xx.xx.2026** - Fixed the network connection not being checked again when the network changed while the dashboard was open (e.g. a cable unplugged or a VPN connected), although the documentation says so. If the dashboard is not open, it is checked when it is opened again. [#PR](PRLINK) - Fixed the gateway / router not being found (shown as failed although the internet works) for VPN connections whose adapter is not an Ethernet or Wi-Fi adapter (e.g. the Windows VPN client with IKEv2 / SSTP). A VPN adapter without a gateway is no longer shown with the gateway `0.0.0.0`. [#PR](PRLINK) - Fixed an IP address on an error page or the page of a hotspot / captive portal (e.g. hotel Wi-Fi) being shown as the public IP address. The answer of the API must have a success status code, a private IP address is shown as a warning, and an API name that can't be resolved points to the DNS server. The public IPv4 and IPv6 addresses are requested at the same time. [#PR](PRLINK) +- Fixed custom public IPv6 address APIs that answer with a JSON object (e.g. `{"ip":"2001:db8::1"}`) not being recognized. A custom API may answer with the IP address as plain text or in a JSON object; other answers (e.g. the HTML page of a captive portal) are no longer searched for an IP address. [#PR](PRLINK) **Status window** From 1e431b62af09c11bcd79853ee84cf07b12a2729a Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:04:45 +0100 Subject: [PATCH 28/56] Fix: Dashboard: No internet DNS name for a private IP address from the API (CR4) A private address (e.g. answer of a captive portal) was resolved and its PTR shown as the DNS name of the internet connection with state OK. Co-Authored-By: Claude Opus 5.5 --- .../ViewModels/NetworkConnectionWidgetViewModel.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index 58ff57e015..caf31a0c63 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -526,7 +526,8 @@ private static async Task PingPublicIPAddressAsync(string ipAddress, A /// Item of the internet check (IPv4 or IPv6). /// IPv4 or IPv6. /// Internet connectivity reported by Windows (read once per check). - /// The IP address returned by the API (also if private), or null. + /// The public IP address returned by the API, or null (also if the API returned a private one, e.g. + /// a captive portal - its DNS name is not the one of the internet connection). private static async Task CheckInternetAsync(ConnectionCheckItem item, AddressFamily addressFamily, Task connectivityLevelTask) { @@ -552,7 +553,7 @@ private static async Task CheckInternetAsync(ConnectionCheckItem item publicIPAddress, connectivityLevelTask.Result), publicIPAddress?.IPAddress?.ToString() ?? (isPingSuccessful ? pingInfo.IPAddress.ToString() : null)); - return publicIPAddress?.IPAddress; + return publicIPAddress is { Status: PublicIPAddressCheckStatus.Success } ? publicIPAddress.IPAddress : null; } /// From 3c033307a799f2a8f8ac971687e862afac16e6ca Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:05:12 +0100 Subject: [PATCH 29/56] Fix: Dashboard: Show the main window before the "application not found" message (CR5) Opening a hidden tool from the status window showed the error on the main window in the tray. Co-Authored-By: Claude Opus 5.5 --- Source/NETworkManager/MainWindow.xaml.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/NETworkManager/MainWindow.xaml.cs b/Source/NETworkManager/MainWindow.xaml.cs index e3cc5a3e1b..a590b5715f 100644 --- a/Source/NETworkManager/MainWindow.xaml.cs +++ b/Source/NETworkManager/MainWindow.xaml.cs @@ -1089,6 +1089,9 @@ private void ListViewApplication_OnSelectionChanged(object sender, private async void NavigationManager_ApplicationRequested(object sender, ApplicationRequest request) { + // Requested from another window (e.g. the status window): show the main window, also for the error message below + ShowWindow(); + // Clear the search, otherwise the application may be filtered out ApplicationSearch = string.Empty; @@ -1105,9 +1108,6 @@ await DialogHelper.ShowMessageAsync(Application.Current.MainWindow, Strings.Erro return; } - // Requested from another window (e.g. the status window): show the main window - ShowWindow(); - if (SettingsViewIsOpen) CloseSettings(); From b89c893ac8cb145ff0720052ada40d3363950322 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:05:39 +0100 Subject: [PATCH 30/56] Fix: Dashboard: Run a requested check also after a failed check (CR6) The error ended the repeat loop, a check requested in the meantime (e.g. network change) was dropped. Co-Authored-By: Claude Opus 5.5 --- .../NetworkConnectionWidgetViewModel.cs | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index caf31a0c63..3b0d3e6162 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -204,25 +204,31 @@ private async Task CheckAsync() { _recheckPending = false; - Log.Info("Checking network connection..."); - - // Takes at least the refresh interval, so the reload animation is visible and the check can't be - // spammed - the checks run at the same time - await TaskHelper.WithMinimumDurationAsync(RunTask, GlobalStaticConfiguration.ApplicationUIRefreshInterval); + try + { + Log.Info("Checking network connection..."); + + // Takes at least the refresh interval, so the reload animation is visible and the check can't be + // spammed - the checks run at the same time + await TaskHelper.WithMinimumDurationAsync(RunTask, + GlobalStaticConfiguration.ApplicationUIRefreshInterval); + + Log.Info("Network connection check completed."); + } + catch (Exception ex) + { + Log.Error("Network connection check failed.", ex); + + // Don't leave the remaining rows loading until the next check + foreach (var item in GetAllItems().Where(x => x.IsChecking)) + item.Complete("-/-", ConnectionState.Critical); + } LastCheckTime = DateTime.Now; - Log.Info("Network connection check completed."); + // A check requested in the meantime (e.g. a network change) runs also after an error } while (_recheckPending); } - catch (Exception ex) - { - Log.Error("Network connection check failed.", ex); - - // Don't leave the remaining rows loading until the next check - foreach (var item in GetAllItems().Where(x => x.IsChecking)) - item.Complete("-/-", ConnectionState.Critical); - } finally { IsChecking = false; From f012e4674198d95896aac378bb32b3812576eef6 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:06:07 +0100 Subject: [PATCH 31/56] Fix: Status window: Configure the DNS client on the UI thread after a network change (CR7) It could overlap with ConfigureDNSServerDispatcherTimer_Tick (DNS settings changed at the same time) and apply the older settings last. Co-Authored-By: Claude Opus 5.5 --- Source/NETworkManager/MainWindow.xaml.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/NETworkManager/MainWindow.xaml.cs b/Source/NETworkManager/MainWindow.xaml.cs index a590b5715f..6080cc8c6c 100644 --- a/Source/NETworkManager/MainWindow.xaml.cs +++ b/Source/NETworkManager/MainWindow.xaml.cs @@ -1877,7 +1877,7 @@ private void OnNetworkHasChanged() }); } - private async void NetworkChangeDispatcherTimer_Tick(object sender, EventArgs e) + private void NetworkChangeDispatcherTimer_Tick(object sender, EventArgs e) { _networkChangeDispatcherTimer.Stop(); @@ -1885,10 +1885,11 @@ private async void NetworkChangeDispatcherTimer_Tick(object sender, EventArgs e) // Reconfigure the DNS client if network changed - re-detects the Windows default DNS servers // and, if enabled, the auto-detected DNS suffix (both of which can differ on the new network). + // On the UI thread like after a change of the DNS settings, so both can't overlap (the last one wins). try { Log.Info("Update DNS server configuration..."); - await Task.Run(ConfigureDNSServer); + ConfigureDNSServer(); } catch (Exception ex) { From 112300ed56b287938add5f92810aaabb7307ed19 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:06:32 +0100 Subject: [PATCH 32/56] Fix: Status window: Clicking into it at the end of the countdown keeps it open (CR8) Co-Authored-By: Claude Opus 5.5 --- Source/NETworkManager/StatusWindow.xaml.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/NETworkManager/StatusWindow.xaml.cs b/Source/NETworkManager/StatusWindow.xaml.cs index 924fd55b27..9e93afa647 100644 --- a/Source/NETworkManager/StatusWindow.xaml.cs +++ b/Source/NETworkManager/StatusWindow.xaml.cs @@ -232,8 +232,9 @@ private void HideWindow() private void MetroWindow_Activated(object sender, EventArgs e) { - // The user clicked into the window that was opened on a network change: keep it open (like opened by the user) - if (_dispatcherTimerClose.IsEnabled) + // The user clicked into the window that was opened on a network change: keep it open (like opened by the user). + // ShowTime: the countdown is running or has just ended (the window is hidden after a short delay). + if (ShowTime) StopCloseTimer(); } From e06ad2c656913d0f676de5e513b9bd7913c5c939 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:07:07 +0100 Subject: [PATCH 33/56] Fix: Dashboard: No Web Console for a link-local IPv6 gateway (CR9) The scope id (fe80::1%12) made the URL invalid. Ping Monitor / Traceroute keep the scope id (needed to reach the link-local address). Co-Authored-By: Claude Opus 5.5 --- Source/NETworkManager/ViewModels/ConnectionCheckItem.cs | 9 +++++++++ .../Views/NetworkConnectionWidgetView.xaml | 2 +- Website/docs/application/dashboard.md | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs b/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs index 34c227f60a..cd5a62c406 100644 --- a/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs +++ b/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs @@ -1,4 +1,5 @@ using System.Linq; +using System.Net; using System.Windows.Input; using NETworkManager.Localization; using NETworkManager.Models; @@ -63,6 +64,13 @@ public ConnectionCheckItem(ConnectionCheckItemKind kind) /// public bool IsRouterIPAddress => Kind == ConnectionCheckItemKind.RouterIPAddress; + /// + /// Gets a value indicating whether the target can be opened in the Web Console: the gateway / router, but not a + /// link-local IPv6 address (the scope id, e.g. fe80::1%12, is not valid in a URL). + /// + public bool IsWebConsoleAvailable => IsRouterIPAddress && + !(IPAddress.TryParse(Target, out var ipAddress) && ipAddress.IsIPv6LinkLocal); + /// /// Gets a value indicating whether the value is the public IP address (e.g. IP geolocation, RDAP). /// @@ -147,6 +155,7 @@ public string Target field = value; OnPropertyChanged(); + OnPropertyChanged(nameof(IsWebConsoleAvailable)); } } diff --git a/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml b/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml index c9fd70a08f..935f0071e2 100644 --- a/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml +++ b/Source/NETworkManager/Views/NetworkConnectionWidgetView.xaml @@ -133,7 +133,7 @@ + Visibility="{Binding IsWebConsoleAvailable, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}"> diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index 15ef7a5aff..77a37b321d 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -21,7 +21,7 @@ The **Network connection** widget (also shown in the status window) checks the c | Red | Failed, e.g. the computer has no IPv4 address, the DNS server did not answer, or the internet is not reachable | | Gray | Information, e.g. no IPv6 connection: the network or the internet provider may not support IPv6 (the IPv6 checks of the router and the internet are skipped), or no DNS name (PTR record) for the IP address, which many networks don't have | -Right-click a value to open it in another tool: an IP address in the **Port Scanner**, **Ping Monitor**, **Traceroute** or **DNS Lookup**, the gateway / router also in the **Web Console** (e.g. its web interface), the public IP address also in **RDAP** and **IP Geolocation**, and a DNS name in the **DNS Lookup**. **Copy** copies the value. The **Copy all** button next to the refresh button copies all values with the reasons of the states as text (e.g. for a support request). +Right-click a value to open it in another tool: an IP address in the **Port Scanner**, **Ping Monitor**, **Traceroute** or **DNS Lookup**, the gateway / router also in the **Web Console** (e.g. its web interface, not for a link-local IPv6 address like `fe80::1%12`), the public IP address also in **RDAP** and **IP Geolocation**, and a DNS name in the **DNS Lookup**. **Copy** copies the value. The **Copy all** button next to the refresh button copies all values with the reasons of the states as text (e.g. for a support request). ### Keyboard shortcuts From 43e13d04d542d733588a6c738c7f959cbddba2da Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:10:31 +0100 Subject: [PATCH 34/56] Test: Dashboard: Answer formats of public IP address APIs (T2) Plain text (with / without line break) and JSON of ipify, seeip, my-ip.io, ip-api.com, icanhazip, ifconfig.co, ipinfo, ident.me, checkip.amazonaws.com (real answer format checked); Cloudflare trace (key=value) not supported. Co-Authored-By: Claude Opus 5.5 --- .../Network/PublicIPAddressCheckTests.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs b/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs index 96a8a9540d..13c5c971a3 100644 --- a/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs +++ b/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs @@ -110,6 +110,35 @@ public void GetStatus(string ipAddress, PublicIPAddressCheckStatus expected) Assert.Equal(expected, PublicIPAddressCheck.GetStatus(IPAddress.Parse(ipAddress))); } + // Answer formats of public IP address APIs (examples in the documentation and other common ones), with + // documentation addresses. checkip.amazonaws.com: real answer (line break at the end). + [Theory] + [InlineData("api.ipify.org, ip4.seeip.org, api.my-ip.io/ip, ifconfig.me/ip", "203.0.113.10", AddressFamily.InterNetwork, "203.0.113.10")] + [InlineData("icanhazip.com, ifconfig.co/ip, ipinfo.io/ip, ident.me, checkip.amazonaws.com", "203.0.113.10\n", AddressFamily.InterNetwork, "203.0.113.10")] + [InlineData("ip-api.com/line/?fields=query", "203.0.113.10\n", AddressFamily.InterNetwork, "203.0.113.10")] + [InlineData("api.ipify.org?format=json, api.seeip.org/jsonip", "{\"ip\":\"203.0.113.10\"}", AddressFamily.InterNetwork, "203.0.113.10")] + [InlineData("api.my-ip.io/v2/ip.json", "{\"success\":true,\"ip\":\"203.0.113.10\",\"type\":\"IPv4\"}", AddressFamily.InterNetwork, "203.0.113.10")] + [InlineData("ip-api.com/json", "{\"status\":\"success\",\"country\":\"Germany\",\"countryCode\":\"DE\",\"region\":\"BE\",\"regionName\":\"Land Berlin\",\"city\":\"Berlin\",\"zip\":\"10115\",\"lat\":52.5,\"lon\":13.4,\"timezone\":\"Europe/Berlin\",\"isp\":\"Example ISP\",\"org\":\"\",\"as\":\"AS64496 Example\",\"query\":\"203.0.113.10\"}", AddressFamily.InterNetwork, "203.0.113.10")] + [InlineData("ipinfo.io/json", "{\n \"ip\": \"203.0.113.10\",\n \"hostname\": \"host.example.com\",\n \"city\": \"Berlin\",\n \"loc\": \"52.5244,13.4105\",\n \"readme\": \"https://ipinfo.io/missingauth\"\n}", AddressFamily.InterNetwork, "203.0.113.10")] + [InlineData("ifconfig.co/json", "{\n \"ip\": \"203.0.113.10\",\n \"ip_decimal\": 3405803786,\n \"country\": \"Germany\"\n}", AddressFamily.InterNetwork, "203.0.113.10")] + [InlineData("api6.ipify.org, v6.ident.me", "2001:db8:85a3::8a2e:370:7334", AddressFamily.InterNetworkV6, "2001:db8:85a3::8a2e:370:7334")] + [InlineData("ipv6.icanhazip.com", "2001:db8:85a3::8a2e:370:7334\n", AddressFamily.InterNetworkV6, "2001:db8:85a3::8a2e:370:7334")] + [InlineData("api64.ipify.org?format=json", "{\"ip\":\"2001:db8:85a3::8a2e:370:7334\"}", AddressFamily.InterNetworkV6, "2001:db8:85a3::8a2e:370:7334")] + [InlineData("api.my-ip.io/v2/ip.json (IPv6)", "{\"success\":true,\"ip\":\"2001:db8:85a3::8a2e:370:7334\",\"type\":\"IPv6\"}", AddressFamily.InterNetworkV6, "2001:db8:85a3::8a2e:370:7334")] + // A dual-stack API answering with IPv6 to the IPv4 request: no valid answer for IPv4 + [InlineData("api64.ipify.org (IPv6 answer)", "2001:db8:85a3::8a2e:370:7334", AddressFamily.InterNetwork, null)] + // Cloudflare trace (key=value lines, h= is the host, not the client): not supported + [InlineData("1.1.1.1/cdn-cgi/trace", "fl=123f45\nh=1.1.1.1\nip=203.0.113.10\nts=1700000000.123\n", AddressFamily.InterNetwork, null)] + public void ParseResponse_KnownAPIs(string api, string content, AddressFamily addressFamily, string expected) + { + var result = PublicIPAddressCheck.ParseResponse(true, content, addressFamily); + + Assert.True(expected == null + ? result.Status == PublicIPAddressCheckStatus.InvalidResponse + : result.Status == PublicIPAddressCheckStatus.Success && result.IPAddress.Equals(IPAddress.Parse(expected)), + $"{api}: {result.Status} {result.IPAddress}"); + } + [Fact] public void FromException_NameResolutionFailed() { From 5e845fadcf662d692543a853063f2cc006617331 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:14:10 +0100 Subject: [PATCH 35/56] Docs: Dashboard: More examples for the custom public IP address APIs checked with their real answers: ipify (plain / JSON), checkip.amazonaws.com, ifconfig.co, ipinfo.io; ip-api.com (format only, http / 45 per minute); JSON with more fields; key=value (Cloudflare trace) not supported. Co-Authored-By: Claude Opus 5.5 --- Website/docs/application/dashboard.md | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index 77a37b321d..11b5c66ee6 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -75,9 +75,18 @@ Override the default IPv4 address API to resolve the public IP address. The API **Example:** -- [`api.ipify.org`](https://api.ipify.org/) -- [`ip4.seeip.org`](https://ip4.seeip.org/) -- [`api.my-ip.io/ip`](https://api.my-ip.io/ip) +| API | Answer | +|-----|--------| +| [`https://api.ipify.org`](https://api.ipify.org/) | Plain text | +| [`https://api.ipify.org?format=json`](https://api.ipify.org?format=json) | JSON `{"ip":"xx.xx.xx.xx"}` | +| [`https://checkip.amazonaws.com`](https://checkip.amazonaws.com/) | Plain text | +| [`https://ifconfig.co/ip`](https://ifconfig.co/ip) | Plain text | +| [`https://ipinfo.io/ip`](https://ipinfo.io/ip) | Plain text | +| [`https://ip4.seeip.org`](https://ip4.seeip.org/) | Plain text | +| [`https://api.my-ip.io/ip`](https://api.my-ip.io/ip) | Plain text | +| [`http://ip-api.com/line/?fields=query`](http://ip-api.com/line/?fields=query) | Plain text (`http` only, 45 requests per minute, non-commercial use only) | + +Many APIs also return JSON with more information (e.g. `https://ipinfo.io/json`, `https://ifconfig.co/json`, `http://ip-api.com/json`), the first string value that is an IP address is used. An API that returns `key=value` lines (e.g. `https://1.1.1.1/cdn-cgi/trace`) is not supported. ### Use custom IPv6 address API @@ -89,7 +98,12 @@ Override the default IPv6 address API to resolve the public IP address. The API **Example:** -- [`api6.ipify.org`](https://api6.ipify.org/) +| API | Answer | +|-----|--------| +| [`https://api6.ipify.org`](https://api6.ipify.org/) | Plain text | +| [`https://api64.ipify.org?format=json`](https://api64.ipify.org?format=json) | JSON `{"ip":"xxxx:xx:xxx::xx"}` (IPv6 if available, otherwise IPv4 - then the answer is not accepted) | +| [`https://ipv6.icanhazip.com`](https://ipv6.icanhazip.com/) | Plain text | +| [`https://v6.ident.me`](https://v6.ident.me/) | Plain text | ### Check IP geolocation From 9f422bd410f357b099259f97f8575e938d0eba78 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:19:59 +0100 Subject: [PATCH 36/56] Fix: Status window: A network change doesn't close a window opened by the user (CR10) The close timer was started on a visible, active window; Activated is not raised again, so clicking into it couldn't stop the countdown. Co-Authored-By: Claude Opus 5.5 --- Source/NETworkManager/StatusWindow.xaml.cs | 7 +++++++ Website/docs/changelog/next-release.md | 1 + 2 files changed, 8 insertions(+) diff --git a/Source/NETworkManager/StatusWindow.xaml.cs b/Source/NETworkManager/StatusWindow.xaml.cs index 9e93afa647..9fdda3984c 100644 --- a/Source/NETworkManager/StatusWindow.xaml.cs +++ b/Source/NETworkManager/StatusWindow.xaml.cs @@ -140,6 +140,13 @@ private void Check() /// Automatically close the window after a certain time. public void ShowWindow(bool enableCloseTimer = false) { + // A network change while the user has the window open (no countdown): keep it open, only check again + if (enableCloseTimer && IsVisible && !ShowTime) + { + Check(); + return; + } + // Position bottom-right on the primary screen. With SizeToContent="Height" the final // height is only known after layout, so this is refined again in SizeChanged. UpdatePosition(); diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 85c4dd97bf..1f56f570ac 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -153,6 +153,7 @@ Release date: **xx.xx.2026** - The status window that opens on a network change no longer takes the keyboard focus from the application you are working in. Clicking into it keeps it open (the countdown stops). [#PR](PRLINK) - Fixed the status window being hidden right after it was opened from the tray icon when the countdown of a previous network change had just ended. [#PR](PRLINK) - Fixed the status window being cut off on the left on small screens (e.g. 1280 x 720 with 150 % scaling). It is no longer wider than the screen. [#PR](PRLINK) +- Fixed the status window opened by the user (e.g. from the tray icon) closing itself after a network change. It stays open and checks the network connection again. [#PR](PRLINK) ## Dependencies, Refactoring & Documentation From 7332a36c7de0074176b63a4f3259d833ce81f17f Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:20:27 +0100 Subject: [PATCH 37/56] Fix: Status window: Handle a network that keeps changing (CR11) The timer of the trailing debounce is not restarted after 3 x the delay (15 s), so the change is handled at the latest after 20 s. Co-Authored-By: Claude Opus 5.5 --- Source/NETworkManager/MainWindow.xaml.cs | 18 ++++++++++++++++++ Website/docs/changelog/next-release.md | 2 +- Website/docs/settings/status.md | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Source/NETworkManager/MainWindow.xaml.cs b/Source/NETworkManager/MainWindow.xaml.cs index 6080cc8c6c..7aa313d405 100644 --- a/Source/NETworkManager/MainWindow.xaml.cs +++ b/Source/NETworkManager/MainWindow.xaml.cs @@ -129,6 +129,13 @@ private void OnPropertyChanged([CallerMemberName] string propertyName = null) /// private readonly DispatcherTimer _networkChangeDispatcherTimer = new(); + /// + /// First network change event since the last handled change. The timer is not restarted anymore after 3 times + /// , so a network that keeps changing (e.g. + /// flapping Wi-Fi, VPN reconnects) is still handled. + /// + private DateTime _firstNetworkChange; + private readonly bool _isLoading; private bool _isProfileFilesLoading; private bool _isProfileFileUpdating; @@ -1872,6 +1879,17 @@ private void OnNetworkHasChanged() { Dispatcher.InvokeAsync(() => { + if (!_networkChangeDispatcherTimer.IsEnabled) + { + _firstNetworkChange = DateTime.Now; + } + else if (DateTime.Now - _firstNetworkChange >= + TimeSpan.FromMilliseconds(GlobalStaticConfiguration.NetworkChangeDetectionDelay * 3)) + { + // Waited long enough: let the running timer handle the change + return; + } + _networkChangeDispatcherTimer.Stop(); _networkChangeDispatcherTimer.Start(); }); diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 1f56f570ac..fa0e8a5cc3 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -149,7 +149,7 @@ Release date: **xx.xx.2026** **Status window** -- The status window now opens after a network change once the network has settled (5 seconds without further changes, e.g. after the DHCP address was assigned) instead of 5 seconds after the first change, so it no longer shows an intermediate state. An error while updating the DNS configuration after a network change no longer stops the detection of further network changes. [#PR](PRLINK) +- The status window now opens after a network change once the network has settled (5 seconds without further changes, e.g. after the DHCP address was assigned, at most 20 seconds after the first change) instead of 5 seconds after the first change, so it no longer shows an intermediate state. An error while updating the DNS configuration after a network change no longer stops the detection of further network changes. [#PR](PRLINK) - The status window that opens on a network change no longer takes the keyboard focus from the application you are working in. Clicking into it keeps it open (the countdown stops). [#PR](PRLINK) - Fixed the status window being hidden right after it was opened from the tray icon when the countdown of a previous network change had just ended. [#PR](PRLINK) - Fixed the status window being cut off on the left on small screens (e.g. 1280 x 720 with 150 % scaling). It is no longer wider than the screen. [#PR](PRLINK) diff --git a/Website/docs/settings/status.md b/Website/docs/settings/status.md index 61b6202cc5..86015ee9d6 100644 --- a/Website/docs/settings/status.md +++ b/Website/docs/settings/status.md @@ -8,7 +8,7 @@ keywords: [NETworkManager, status settings, status window, network change notifi ### Show status window on network change -Show the status window when the network changes (e.g. Ethernet cable is plugged in, WLAN or VPN is connected, etc.). The window opens once the network has settled (5 seconds without further changes, e.g. after the DHCP address was assigned) and checks the network connection, see [Dashboard](../application/dashboard.md#network-connection). It doesn't take the keyboard focus; click into it to keep it open. +Show the status window when the network changes (e.g. Ethernet cable is plugged in, WLAN or VPN is connected, etc.). The window opens once the network has settled (5 seconds without further changes, e.g. after the DHCP address was assigned, at most 20 seconds after the first change) and checks the network connection, see [Dashboard](../application/dashboard.md#network-connection). It doesn't take the keyboard focus; click into it to keep it open. **Type:** `Boolean` From 21cc2b63832804c19a349255ba14bd6816d721be Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:20:56 +0100 Subject: [PATCH 38/56] Fix: Dashboard: A public IP address from the API wins over the captive portal of Windows (CR12) A web filter / proxy intercepting the probe of Windows showed a permanent captive portal warning although the HTTPS request to the API worked. Co-Authored-By: Claude Opus 5.5 --- .../Network/NetworkConnectionCheck.cs | 12 ++++++++---- .../Network/NetworkConnectionCheckTests.cs | 7 +++++-- Website/docs/application/dashboard.md | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs b/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs index b41765eeea..ccb4bf4131 100644 --- a/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs +++ b/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs @@ -127,9 +127,10 @@ public static ConnectionCheckResult GetPublicIPAddressResult(PublicIPAddressChec /// (setting), the public IP address API (if enabled) and the connectivity reported by Windows. /// /// - /// A captive portal (Windows) is a warning. Otherwise a public IP address from the API or a reply to the ping is - /// OK; a private IP address from the API is a warning, as is a failed API when the ping works (e.g. the API is - /// blocked). If both fail but Windows reports internet access (only used for IPv4, Windows doesn't report it per + /// A public IP address from the API is OK (the HTTPS request reached the internet), even if Windows reports a + /// captive portal (e.g. a proxy or web filter intercepts the probe of Windows). Otherwise a captive portal + /// (Windows) is a warning; a reply to the ping is OK; a private IP address from the API is a warning, as is a + /// failed API when the ping works (e.g. the API is blocked). If both fail but Windows reports internet access (only used for IPv4, Windows doesn't report it per /// address family), ICMP and the API may be blocked: warning. Otherwise critical. /// /// IPv4 or IPv6. @@ -140,10 +141,13 @@ public static ConnectionCheckResult GetPublicIPAddressResult(PublicIPAddressChec public static ConnectionCheckResult GetInternetResult(AddressFamily addressFamily, bool isPingSuccessful, PublicIPAddressCheckResult publicIPAddress, InternetConnectivityLevel connectivityLevel) { + if (publicIPAddress is { Status: PublicIPAddressCheckStatus.Success }) + return new ConnectionCheckResult(ConnectionState.OK); + if (connectivityLevel == InternetConnectivityLevel.ConstrainedInternetAccess) return new ConnectionCheckResult(ConnectionState.Warning, ConnectionCheckReason.CaptivePortal); - if (publicIPAddress is { Status: PublicIPAddressCheckStatus.Success or PublicIPAddressCheckStatus.PrivateIPAddress }) + if (publicIPAddress is { Status: PublicIPAddressCheckStatus.PrivateIPAddress }) return GetPublicIPAddressResult(publicIPAddress); if (isPingSuccessful) diff --git a/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs index 6606d6f4b1..f1e9821951 100644 --- a/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs +++ b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs @@ -137,9 +137,12 @@ private static PublicIPAddressCheckResult Api(PublicIPAddressCheckStatus? status // API disabled: ping decides [InlineData(true, null, InternetConnectivityLevel.InternetAccess, ConnectionState.OK, ConnectionCheckReason.None)] [InlineData(false, null, InternetConnectivityLevel.LocalAccess, ConnectionState.Critical, ConnectionCheckReason.InternetNotReachable)] - // Captive portal (Windows) always wins - [InlineData(true, PublicIPAddressCheckStatus.Success, InternetConnectivityLevel.ConstrainedInternetAccess, ConnectionState.Warning, ConnectionCheckReason.CaptivePortal)] + // Captive portal (Windows), unless the API returned a public IP address (e.g. a web filter intercepts the probe + // of Windows, the internet works) + [InlineData(true, PublicIPAddressCheckStatus.Success, InternetConnectivityLevel.ConstrainedInternetAccess, ConnectionState.OK, ConnectionCheckReason.None)] + [InlineData(true, null, InternetConnectivityLevel.ConstrainedInternetAccess, ConnectionState.Warning, ConnectionCheckReason.CaptivePortal)] [InlineData(false, null, InternetConnectivityLevel.ConstrainedInternetAccess, ConnectionState.Warning, ConnectionCheckReason.CaptivePortal)] + [InlineData(false, PublicIPAddressCheckStatus.PrivateIPAddress, InternetConnectivityLevel.ConstrainedInternetAccess, ConnectionState.Warning, ConnectionCheckReason.CaptivePortal)] // Private IP address from the API (e.g. proxy) [InlineData(true, PublicIPAddressCheckStatus.PrivateIPAddress, InternetConnectivityLevel.InternetAccess, ConnectionState.Warning, ConnectionCheckReason.PublicIPAddressPrivate)] // Ping works, API blocked / DNS broken diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index 11b5c66ee6..8fc50fb29f 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -17,7 +17,7 @@ The **Network connection** widget (also shown in the status window) checks the c | Icon | Meaning | |------|---------| | Green | OK | -| Yellow | Works partly or may not work, e.g. the computer has only a link-local IPv4 address (`169.254.x.x`, no address from a DHCP server) or no route to the internet (the address of the first active network adapter is shown), the gateway did not reply to the ping (it may block ICMP), the network adapter has no gateway (e.g. a VPN connection), the public IP address API returned a private IP address (e.g. the page of a hotspot / captive portal or a proxy), Windows reports a hotspot / captive portal, the ping works but the public IP address API doesn't, or the ping and the API fail but Windows reports internet access (e.g. both are blocked by a firewall or only reachable via a proxy) | +| Yellow | Works partly or may not work, e.g. the computer has only a link-local IPv4 address (`169.254.x.x`, no address from a DHCP server) or no route to the internet (the address of the first active network adapter is shown), the gateway did not reply to the ping (it may block ICMP), the network adapter has no gateway (e.g. a VPN connection), the public IP address API returned a private IP address (e.g. the page of a hotspot / captive portal or a proxy), Windows reports a hotspot / captive portal (unless the public IP address API returned a public IP address), the ping works but the public IP address API doesn't, or the ping and the API fail but Windows reports internet access (e.g. both are blocked by a firewall or only reachable via a proxy) | | Red | Failed, e.g. the computer has no IPv4 address, the DNS server did not answer, or the internet is not reachable | | Gray | Information, e.g. no IPv6 connection: the network or the internet provider may not support IPv6 (the IPv6 checks of the router and the internet are skipped), or no DNS name (PTR record) for the IP address, which many networks don't have | From 6fe3cb697815d05930a980c63dd62de7dd613ce1 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:21:21 +0100 Subject: [PATCH 39/56] Fix: Dashboard: A private API answer is not opened in other tools (CR13) The target is the public IP address, otherwise the pinged address. Co-Authored-By: Claude Opus 5.5 --- .../ViewModels/NetworkConnectionWidgetViewModel.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index 3b0d3e6162..9abe2cd685 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -555,11 +555,14 @@ private static async Task CheckInternetAsync(ConnectionCheckItem item var value = publicIPAddress?.IPAddress?.ToString() ?? (isPingSuccessful ? $"{pingInfo.IPAddress} ({pingInfo.Time} ms)" : "-/-"); + // Public IP address for the other tools (e.g. RDAP, IP geolocation), not a private one (e.g. a captive portal) + var publicIP = publicIPAddress is { Status: PublicIPAddressCheckStatus.Success } ? publicIPAddress.IPAddress : null; + item.Complete(value, NetworkConnectionCheck.GetInternetResult(addressFamily, isPingSuccessful, - publicIPAddress, connectivityLevelTask.Result), publicIPAddress?.IPAddress?.ToString() ?? - (isPingSuccessful ? pingInfo.IPAddress.ToString() : null)); + publicIPAddress, connectivityLevelTask.Result), + publicIP?.ToString() ?? (isPingSuccessful ? pingInfo.IPAddress.ToString() : null)); - return publicIPAddress is { Status: PublicIPAddressCheckStatus.Success } ? publicIPAddress.IPAddress : null; + return publicIP; } /// From 2eb1bb789250236478760958b92489493842184b Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:21:42 +0100 Subject: [PATCH 40/56] Fix: Dashboard: IPv4-mapped / site-local IPv6 address from the API is not public (CR14) Co-Authored-By: Claude Opus 5.5 --- .../Network/PublicIPAddressCheck.cs | 14 ++++++++++---- .../Network/PublicIPAddressCheckTests.cs | 3 +++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs b/Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs index 267746cada..c6f220a357 100644 --- a/Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs +++ b/Source/NETworkManager.Models/Network/PublicIPAddressCheck.cs @@ -129,8 +129,8 @@ private static bool TryParseIPAddress(string text, AddressFamily addressFamily, /// /// Status of an IP address returned by the API: a private, shared (carrier-grade NAT), link-local or loopback - /// address is not the public IP address (e.g. the answer of a captive portal or a proxy); an unspecified, - /// multicast or reserved address is no valid answer. + /// address (IPv6 also site-local) is not the public IP address (e.g. the answer of a captive portal or a proxy); + /// an unspecified, multicast, reserved or IPv4-mapped IPv6 address is no valid answer. /// /// IP address returned by the API. /// , @@ -149,9 +149,15 @@ public static PublicIPAddressCheckStatus GetStatus(IPAddress ipAddress) if (bytes[0] == 100 && bytes[1] is >= 64 and <= 127) return PublicIPAddressCheckStatus.PrivateIPAddress; } - else if (ipAddress.Equals(IPAddress.IPv6Any) || ipAddress.IsIPv6Multicast) + else { - return PublicIPAddressCheckStatus.InvalidResponse; + // Unspecified, multicast, IPv4-mapped (e.g. ::ffff:10.1.2.3, no IPv6 address) + if (ipAddress.Equals(IPAddress.IPv6Any) || ipAddress.IsIPv6Multicast || ipAddress.IsIPv4MappedToIPv6) + return PublicIPAddressCheckStatus.InvalidResponse; + + // Site-local (fec0::/10, deprecated) + if (ipAddress.IsIPv6SiteLocal) + return PublicIPAddressCheckStatus.PrivateIPAddress; } return IPAddressHelper.IsPrivateIPAddress(ipAddress) || NetworkInterface.IsLinkLocal(ipAddress) || diff --git a/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs b/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs index 13c5c971a3..536aa1643d 100644 --- a/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs +++ b/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs @@ -104,6 +104,9 @@ public void ParseResponse_NotAnIPAddressOrReserved_InvalidResponse(string conten [InlineData("::1", PublicIPAddressCheckStatus.PrivateIPAddress)] [InlineData("fe80::1", PublicIPAddressCheckStatus.PrivateIPAddress)] [InlineData("0.1.2.3", PublicIPAddressCheckStatus.InvalidResponse)] + [InlineData("::ffff:10.1.2.3", PublicIPAddressCheckStatus.InvalidResponse)] + [InlineData("::ffff:203.0.113.10", PublicIPAddressCheckStatus.InvalidResponse)] + [InlineData("fec0::1", PublicIPAddressCheckStatus.PrivateIPAddress)] [InlineData("240.0.0.1", PublicIPAddressCheckStatus.InvalidResponse)] public void GetStatus(string ipAddress, PublicIPAddressCheckStatus expected) { From 7d7ff62b0993e9ba879f1a2250b99cdaa7065174 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:22:15 +0100 Subject: [PATCH 41/56] Fix: Dashboard: Only settings of the network connection skip the recheck interval (CR15) Every Dashboard_* setting (e.g. hiding the Speed Test widget) marked the check as outdated. Co-Authored-By: Claude Opus 5.5 --- .../Views/DashboardView.xaml.cs | 22 +++++++++++++++++-- Website/docs/application/dashboard.md | 2 +- Website/docs/changelog/next-release.md | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Source/NETworkManager/Views/DashboardView.xaml.cs b/Source/NETworkManager/Views/DashboardView.xaml.cs index 8fb5b0e4a1..ccfb7c91d8 100644 --- a/Source/NETworkManager/Views/DashboardView.xaml.cs +++ b/Source/NETworkManager/Views/DashboardView.xaml.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Windows; @@ -24,7 +25,8 @@ public partial class DashboardView private bool _isViewVisible = true; /// - /// The network or a dashboard setting changed while the dashboard was hidden: check again when it is shown. + /// The network or a setting of the network connection check changed while the dashboard was hidden: check again + /// when it is shown. /// private bool _isOutdated; @@ -153,9 +155,25 @@ private void ApplyWidgetSettings() return view; } + /// + /// Settings used by the network connection check: a change marks it as outdated (checked when the dashboard is + /// shown again). Other dashboard settings (e.g. the other widgets) keep the recheck interval. + /// + private static readonly HashSet NetworkConnectionSettings = + [ + nameof(SettingsInfo.Dashboard_PublicIPv4Address), + nameof(SettingsInfo.Dashboard_PublicIPv6Address), + nameof(SettingsInfo.Dashboard_CheckPublicIPAddress), + nameof(SettingsInfo.Dashboard_UseCustomPublicIPv4AddressAPI), + nameof(SettingsInfo.Dashboard_CustomPublicIPv4AddressAPI), + nameof(SettingsInfo.Dashboard_UseCustomPublicIPv6AddressAPI), + nameof(SettingsInfo.Dashboard_CustomPublicIPv6AddressAPI), + nameof(SettingsInfo.Dashboard_ShowNetworkConnectionWidget) + ]; + private void SettingsManager_PropertyChanged(object sender, PropertyChangedEventArgs e) { - if (e.PropertyName?.StartsWith("Dashboard_", StringComparison.Ordinal) == true) + if (e.PropertyName != null && NetworkConnectionSettings.Contains(e.PropertyName)) _isOutdated = true; } } \ No newline at end of file diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index 8fc50fb29f..cf166bdb7c 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -6,7 +6,7 @@ keywords: [NETworkManager, dashboard, network status, network connection, networ # Dashboard -The **Dashboard** shows the status of your computer's current network connection to provide a quick overview of the most important information. Whenever the local network adapter changes state (e.g. an Ethernet cable is plugged in, Wi-Fi or VPN connects), the dashboard checks connectivity to the router and the internet. When you switch back to the dashboard, the network connection is only checked again if the last check is at least 60 seconds old (e.g. the public IP address may have changed) or the network or the dashboard settings have changed in the meantime, so switching between the tools doesn't send a request each time. **F5** or the refresh button always checks again. +The **Dashboard** shows the status of your computer's current network connection to provide a quick overview of the most important information. Whenever the local network adapter changes state (e.g. an Ethernet cable is plugged in, Wi-Fi or VPN connects), the dashboard checks connectivity to the router and the internet. When you switch back to the dashboard, the network connection is only checked again if the last check is at least 60 seconds old (e.g. the public IP address may have changed) or the network or a setting of the network connection (e.g. the public IP address) has changed in the meantime, so switching between the tools doesn't send a request each time. **F5** or the refresh button always checks again. ![Dashboard](../img/dashboard.png) diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index fa0e8a5cc3..9042e62fc4 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -55,7 +55,7 @@ Release date: **xx.xx.2026** **Dashboard** -- Switching back to the dashboard checks the network connection only if the last check is at least 60 seconds old (or the network / the dashboard settings changed), instead of on every switch between the tools. **F5** and the refresh button always check. [#PR](PRLINK) +- Switching back to the dashboard checks the network connection only if the last check is at least 60 seconds old (or the network / a setting of the network connection changed), instead of on every switch between the tools. **F5** and the refresh button always check. [#PR](PRLINK) - The network connection check is faster (also at startup and in the status window): the local IP address and the gateway are read directly from the network adapters instead of querying all adapter details incl. PowerShell up to four times per check. This also speeds up the detection of the local IP address in the **IP Scanner** when no route is available. [#PR](PRLINK) - The network connection shows a warning instead of OK if the computer has only a link-local IPv4 address (`169.254.x.x`, no address from a DHCP server) or no route to the internet. Without an IPv6 connection (e.g. the internet provider doesn't support IPv6), the IPv6 values are shown as information (gray) instead of failed (red), and the IPv6 address of the router and the internet are not checked. Hover over an icon to see the reason. [#PR](PRLINK) - The DNS name (PTR) of the IPv6 address is no longer requested after the DNS server failed for the IPv4 address (the same server would time out again), so the network connection check finishes faster without a working DNS server. Without an IP address to resolve, the DNS value is shown as information instead of failed. [#PR](PRLINK) From 57631b1bf7bcb1666bf4314539cb4897e7ddd30b Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:23:32 +0100 Subject: [PATCH 42/56] Feature: Status window / Notifications: Smooth countdown (S5) The countdown bar uses SmoothProgress like the scanner progress (animated at the frame rate, immediate without animations) instead of 30 steps per second. The close timer of the status window is set up before Show(), so the bar is part of the first layout (no 4 px grow + move after showing). Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 3 ++- Source/NETworkManager/NotificationWindow.xaml | 2 +- Source/NETworkManager/StatusWindow.xaml | 2 +- Source/NETworkManager/StatusWindow.xaml.cs | 9 +++++---- Website/docs/changelog/next-release.md | 8 ++++++++ 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 66a726bd65..9defa01725 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -562,7 +562,8 @@ SemiBold (section headers), `MessageTextBlock` 16 gray (messages in empty areas) - Inputs: radius 4, focus border gray (`Gray5`), hover border `Brushes.Control.Border.MouseOver`. - Drop-downs: `ComboBoxPopupBehavior` (rounded popup with shadow), implicit `ComboBoxItem` style in `DefaultComboBox`. - Progress: `DefaultMetroProgressBar` (accent on a subtle track) and `ProgressRingSmall` / `Medium` / `Large` - (16 inline / 24 dialogs / 48 centered, `ProgressBarStyles.xaml`); scanner progress via `SmoothProgress.Value`. + (16 inline / 24 dialogs / 48 centered, `ProgressBarStyles.xaml`); scanner progress and countdowns (status window, + notifications) via `SmoothProgress.Value`. - Dialogs: `DefaultChildWindow` (own template, radius 8, shadow, overlay, zoom animation) for all dialogs. - Status values in lists (e.g. firewall action, TCP / neighbor state): `StatusDot` (8 px `Ellipse` in front of the text, `Tag` = `StatusLevel` None / Success / Warning / Error via a `*ToStatusLevelConverter`), text in the normal color. diff --git a/Source/NETworkManager/NotificationWindow.xaml b/Source/NETworkManager/NotificationWindow.xaml index 2fec098aa4..6e112f7cc5 100644 --- a/Source/NETworkManager/NotificationWindow.xaml +++ b/Source/NETworkManager/NotificationWindow.xaml @@ -135,7 +135,7 @@ diff --git a/Source/NETworkManager/StatusWindow.xaml b/Source/NETworkManager/StatusWindow.xaml index 778216e572..14b60eecc1 100644 --- a/Source/NETworkManager/StatusWindow.xaml +++ b/Source/NETworkManager/StatusWindow.xaml @@ -58,7 +58,7 @@ Margin="0" Minimum="0" Maximum="{Binding TimeMax, Mode=OneWay}" - Value="{Binding Time, Mode=OneWay}" + networkManager:SmoothProgress.Value="{Binding Time, Mode=OneWay}" Visibility="{Binding ShowTime, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}" BorderThickness="0" Padding="0" /> diff --git a/Source/NETworkManager/StatusWindow.xaml.cs b/Source/NETworkManager/StatusWindow.xaml.cs index 9fdda3984c..fcbc68a959 100644 --- a/Source/NETworkManager/StatusWindow.xaml.cs +++ b/Source/NETworkManager/StatusWindow.xaml.cs @@ -155,18 +155,19 @@ public void ShowWindow(bool enableCloseTimer = false) // closes itself, see the close timer). Clicking into it stops the close timer (Activated). ShowActivated = !enableCloseTimer; + // Close the window after a certain time. Before Show(), so the countdown is part of the first layout (the + // window doesn't grow and move right after it was shown). + if (enableCloseTimer) + SetupCloseTimer(); + // Show the window Show(); // Check the network connection Check(); - // Close the window after a certain time if (enableCloseTimer) - { - SetupCloseTimer(); return; - } // Opened by the user, cancel a running close timer (e.g. if the window was opened on a network change) StopCloseTimer(); diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 9042e62fc4..d3dcbe87ac 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -66,6 +66,14 @@ Release date: **xx.xx.2026** - The network connection shows the time of the last check ("Reloaded at ...") next to the refresh button, like other tools. [#PR](PRLINK) - New **Copy all** button in the network connection: copies all values with the reasons of the states as text, e.g. for a support request. [#PR](PRLINK) +**Status window** + +- The countdown of the status window moves smoothly (like the progress of the IP Scanner) instead of in small steps, and the window no longer grows and moves right after it was opened on a network change. [#PR](PRLINK) + +**Notifications** + +- The countdown of the notifications (e.g. Ping Monitor, IP Scanner) moves smoothly, like the progress of the IP Scanner, instead of in small steps. [#PR](PRLINK) + ## Bug Fixes **Tabs** From 7a15ca0b4d6087517845892529be9d304787a2b0 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:30:03 +0100 Subject: [PATCH 43/56] Fix: Dashboard: The pinged address is not opened in other tools as the public IP (CR16) Without a public IP address from the API, the Internet rows offered RDAP / IP geolocation for the pinged address (e.g. 1.1.1.1). Only the public IP address from the API is a target now (empty target = none). Co-Authored-By: Claude Opus 5.5 --- .../NETworkManager/ViewModels/ConnectionCheckItem.cs | 10 +++++++--- .../ViewModels/NetworkConnectionWidgetViewModel.cs | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs b/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs index cd5a62c406..7f509248cf 100644 --- a/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs +++ b/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs @@ -177,11 +177,14 @@ public void Reset() /// Value shown (-/- if there is none). /// State of the check. /// Reason of the state (tooltip), null if none. - /// IP address or DNS name for other tools, by default the value (if there is one). + /// IP address or DNS name for other tools, by default the value (if there is one), an empty + /// string for none. public void Complete(string value, ConnectionState state, string message = null, string target = null) { Value = value; - Target = target ?? (string.IsNullOrEmpty(value) || value == "-/-" ? null : value); + Target = target != null + ? target.Length == 0 ? null : target + : string.IsNullOrEmpty(value) || value == "-/-" ? null : value; State = state; Message = message; IsChecking = false; @@ -192,7 +195,8 @@ public void Complete(string value, ConnectionState state, string message = null, /// /// Value shown (-/- if there is none). /// State and reason. - /// IP address or DNS name for other tools, by default the value (if there is one). + /// IP address or DNS name for other tools, by default the value (if there is one), an empty + /// string for none. public void Complete(string value, ConnectionCheckResult result, string target = null) { Complete(value, result.State, result.Reason == ConnectionCheckReason.None diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index 9abe2cd685..f72c36f8ae 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -555,7 +555,8 @@ private static async Task CheckInternetAsync(ConnectionCheckItem item var value = publicIPAddress?.IPAddress?.ToString() ?? (isPingSuccessful ? $"{pingInfo.IPAddress} ({pingInfo.Time} ms)" : "-/-"); - // Public IP address for the other tools (e.g. RDAP, IP geolocation), not a private one (e.g. a captive portal) + // Only the public IP address is opened in other tools (e.g. RDAP, IP geolocation): not a private one (e.g. a + // captive portal) and not the pinged address (e.g. 1.1.1.1, it is not the IP address of the user) var publicIP = publicIPAddress is { Status: PublicIPAddressCheckStatus.Success } ? publicIPAddress.IPAddress : null; item.Complete(value, NetworkConnectionCheck.GetInternetResult(addressFamily, isPingSuccessful, From 870f47f0d008567ec3c23773abf97def12ce1529 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:30:04 +0100 Subject: [PATCH 44/56] Fix: Dashboard: No DNS lookup for a link-local IPv4 address of the computer (CR17) Without a DHCP server (169.254.x.x) the PTR lookup failed and Computer > DNS was shown as DNS error instead of "no IP address to resolve". Co-Authored-By: Claude Opus 5.5 --- .../ViewModels/NetworkConnectionWidgetViewModel.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index f72c36f8ae..97ed141296 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -269,8 +269,11 @@ private async Task RunTask() // Without a routed IPv6 address, the IPv6 checks of the router and the internet are not available var isIPv6Available = computerIPv6Result.State == ConnectionState.OK; + // No DNS name of a link-local IPv4 address (no DHCP server): the lookup fails and would point to the DNS server + var resolveIPv4 = localIPv4 != null && !NetworkInterface.IsLinkLocal(localIPv4) ? localIPv4 : null; + await Task.WhenAll( - CheckConnectionComputerDnsAsync(localIPv4, isIPv6Available ? localIPv6 : null), + CheckConnectionComputerDnsAsync(resolveIPv4, isIPv6Available ? localIPv6 : null), CheckConnectionRouterAsync(localIPv4, isIPv4Routed, isIPv6Available ? localIPv6 : null), CheckConnectionInternetAsync(isIPv6Available) ); @@ -560,8 +563,7 @@ private static async Task CheckInternetAsync(ConnectionCheckItem item var publicIP = publicIPAddress is { Status: PublicIPAddressCheckStatus.Success } ? publicIPAddress.IPAddress : null; item.Complete(value, NetworkConnectionCheck.GetInternetResult(addressFamily, isPingSuccessful, - publicIPAddress, connectivityLevelTask.Result), - publicIP?.ToString() ?? (isPingSuccessful ? pingInfo.IPAddress.ToString() : null)); + publicIPAddress, connectivityLevelTask.Result), publicIP?.ToString() ?? string.Empty); return publicIP; } From 83858c6e9fa8144e6aa383dddea0de46f6724739 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:30:16 +0100 Subject: [PATCH 45/56] Docs: Dashboard: Changelog of B1 matches the behavior (refresh disabled while checking) Co-Authored-By: Claude Opus 5.5 --- Website/docs/changelog/next-release.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index d3dcbe87ac..54185c904f 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -148,7 +148,7 @@ Release date: **xx.xx.2026** **Dashboard** -- Fixed the network connection check getting stuck (all values loading until the next refresh) when the refresh was used several times while a check was running. A refresh during a check now repeats the check once it has finished. [#PR](PRLINK) +- Fixed the network connection check getting stuck (all values loading until the next refresh) when it was started several times while a check was running (e.g. the refresh and a network change). The refresh is disabled while a check runs, a network change during a check repeats the check once it has finished. [#PR](PRLINK) - Fixed the network connection widget (dashboard and status window) not updating when **Check public IP address** was changed in the settings until the application was restarted: an old public IP address could be shown as current. [#PR](PRLINK) - Fixed the network connection not being checked again when the network changed while the dashboard was open (e.g. a cable unplugged or a VPN connected), although the documentation says so. If the dashboard is not open, it is checked when it is opened again. [#PR](PRLINK) - Fixed the gateway / router not being found (shown as failed although the internet works) for VPN connections whose adapter is not an Ethernet or Wi-Fi adapter (e.g. the Windows VPN client with IKEv2 / SSTP). A VPN adapter without a gateway is no longer shown with the gateway `0.0.0.0`. [#PR](PRLINK) From a4ebe68e1c3b0e00324c878b0dad9b313b417a96 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:30:16 +0100 Subject: [PATCH 46/56] Docs: Dashboard: Breaking change for custom public IP address APIs (CR2) Co-Authored-By: Claude Opus 5.5 --- Website/docs/changelog/next-release.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 54185c904f..f38faaff99 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -19,6 +19,10 @@ Release date: **xx.xx.2026** ## Breaking Changes +**Dashboard** + +- A custom public IP address API (**Settings > Dashboard**) must return the IP address as plain text or in a JSON object (e.g. `{"ip":"xx.xx.xx.xx"}`). An address inside other text or an HTML page (e.g. `checkip.dyndns.org`) is no longer used, because the page of a hotspot / captive portal could be shown as the public IP address. See the [examples](../application/dashboard.md#use-custom-ipv4-address-api). [#PR](PRLINK) + ## What's new? **Network Interface** From 3a3dc91ad0f882a97c4995fe7e8ab2c59697ee98 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:36:36 +0100 Subject: [PATCH 47/56] Fix: Dashboard: Captive portal of Windows only for IPv4 (CR18) Windows doesn't report the connectivity per address family; a working IPv6 ping showed a captive portal warning. Co-Authored-By: Claude Opus 5.5 --- .../Network/NetworkConnectionCheck.cs | 6 ++++-- .../Network/NetworkConnectionCheckTests.cs | 11 +++++++++++ Website/docs/application/dashboard.md | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs b/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs index ccb4bf4131..3a0964e655 100644 --- a/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs +++ b/Source/NETworkManager.Models/Network/NetworkConnectionCheck.cs @@ -129,7 +129,7 @@ public static ConnectionCheckResult GetPublicIPAddressResult(PublicIPAddressChec /// /// A public IP address from the API is OK (the HTTPS request reached the internet), even if Windows reports a /// captive portal (e.g. a proxy or web filter intercepts the probe of Windows). Otherwise a captive portal - /// (Windows) is a warning; a reply to the ping is OK; a private IP address from the API is a warning, as is a + /// (Windows, only used for IPv4) is a warning, also if the ping works (a captive portal may let ICMP through); a reply to the ping is OK; a private IP address from the API is a warning, as is a /// failed API when the ping works (e.g. the API is blocked). If both fail but Windows reports internet access (only used for IPv4, Windows doesn't report it per /// address family), ICMP and the API may be blocked: warning. Otherwise critical. /// @@ -144,7 +144,9 @@ public static ConnectionCheckResult GetInternetResult(AddressFamily addressFamil if (publicIPAddress is { Status: PublicIPAddressCheckStatus.Success }) return new ConnectionCheckResult(ConnectionState.OK); - if (connectivityLevel == InternetConnectivityLevel.ConstrainedInternetAccess) + // Windows doesn't report the connectivity per address family (a captive portal is IPv4 in practice) + if (addressFamily == AddressFamily.InterNetwork && + connectivityLevel == InternetConnectivityLevel.ConstrainedInternetAccess) return new ConnectionCheckResult(ConnectionState.Warning, ConnectionCheckReason.CaptivePortal); if (publicIPAddress is { Status: PublicIPAddressCheckStatus.PrivateIPAddress }) diff --git a/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs index f1e9821951..3e57fc705b 100644 --- a/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs +++ b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs @@ -162,6 +162,17 @@ public void GetInternetResult_IPv4(bool isPingSuccessful, PublicIPAddressCheckSt NetworkConnectionCheck.GetInternetResult(AddressFamily.InterNetwork, isPingSuccessful, Api(apiStatus), level)); } + [Theory] + [InlineData(true, ConnectionState.OK, ConnectionCheckReason.None)] + [InlineData(false, ConnectionState.Critical, ConnectionCheckReason.InternetNotReachable)] + public void GetInternetResult_IPv6_CaptivePortalOfWindowsIsNotUsed(bool isPingSuccessful, ConnectionState state, + ConnectionCheckReason reason) + { + Assert.Equal(new ConnectionCheckResult(state, reason), + NetworkConnectionCheck.GetInternetResult(AddressFamily.InterNetworkV6, isPingSuccessful, null, + InternetConnectivityLevel.ConstrainedInternetAccess)); + } + [Fact] public void GetInternetResult_IPv6_WindowsInternetAccessIsNotUsed() { diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index cf166bdb7c..93430ede9c 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -17,7 +17,7 @@ The **Network connection** widget (also shown in the status window) checks the c | Icon | Meaning | |------|---------| | Green | OK | -| Yellow | Works partly or may not work, e.g. the computer has only a link-local IPv4 address (`169.254.x.x`, no address from a DHCP server) or no route to the internet (the address of the first active network adapter is shown), the gateway did not reply to the ping (it may block ICMP), the network adapter has no gateway (e.g. a VPN connection), the public IP address API returned a private IP address (e.g. the page of a hotspot / captive portal or a proxy), Windows reports a hotspot / captive portal (unless the public IP address API returned a public IP address), the ping works but the public IP address API doesn't, or the ping and the API fail but Windows reports internet access (e.g. both are blocked by a firewall or only reachable via a proxy) | +| Yellow | Works partly or may not work, e.g. the computer has only a link-local IPv4 address (`169.254.x.x`, no address from a DHCP server) or no route to the internet (the address of the first active network adapter is shown), the gateway did not reply to the ping (it may block ICMP), the network adapter has no gateway (e.g. a VPN connection), the public IP address API returned a private IP address (e.g. the page of a hotspot / captive portal or a proxy), Windows reports a hotspot / captive portal (IPv4, unless the public IP address API returned a public IP address), the ping works but the public IP address API doesn't, or the ping and the API fail but Windows reports internet access (e.g. both are blocked by a firewall or only reachable via a proxy) | | Red | Failed, e.g. the computer has no IPv4 address, the DNS server did not answer, or the internet is not reachable | | Gray | Information, e.g. no IPv6 connection: the network or the internet provider may not support IPv6 (the IPv6 checks of the router and the internet are skipped), or no DNS name (PTR record) for the IP address, which many networks don't have | From bebdf812365c6578c5a6e5eb1ffb16ba5e06980a Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:36:59 +0100 Subject: [PATCH 48/56] Fix: Dashboard: Refresh / copy all enabled right after the check (CR19) CommandManager.InvalidateRequerySuggested when the check ends; CanExecute was only evaluated on the next input. Co-Authored-By: Claude Opus 5.5 --- .../ViewModels/NetworkConnectionWidgetViewModel.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index 97ed141296..be5db2cb4a 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -232,6 +232,10 @@ await TaskHelper.WithMinimumDurationAsync(RunTask, finally { IsChecking = false; + + // Enable the refresh / copy all buttons (CanExecute is otherwise only evaluated on the next input, e.g. not + // in the status window opened on a network change without the focus) + CommandManager.InvalidateRequerySuggested(); } } From f7e1506815d58e96837dc45cb2f7e525d44ed494 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:37:22 +0100 Subject: [PATCH 49/56] Fix: Dashboard: No check of a network connection widget that was not created yet (CR20) Co-Authored-By: Claude Opus 5.5 --- Source/NETworkManager/Views/DashboardView.xaml.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/NETworkManager/Views/DashboardView.xaml.cs b/Source/NETworkManager/Views/DashboardView.xaml.cs index ccfb7c91d8..31ac3812b8 100644 --- a/Source/NETworkManager/Views/DashboardView.xaml.cs +++ b/Source/NETworkManager/Views/DashboardView.xaml.cs @@ -85,8 +85,9 @@ public void OnNetworkChanged() private void CheckNetworkConnection() { - // Hidden: checked when it is shown (a changed setting marks the data as outdated) - if (!SettingsManager.Current.Dashboard_ShowNetworkConnectionWidget) + // Hidden or not created yet: checked when it is shown (a changed setting marks the data as outdated, the widget + // is created in OnViewVisible) + if (!SettingsManager.Current.Dashboard_ShowNetworkConnectionWidget || _networkConnectionWidgetView == null) return; _isOutdated = false; From 2d855f8390a51f7596eea59cfe6ad2336b44da70 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:37:48 +0100 Subject: [PATCH 50/56] Fix: Dashboard: Router without an IPv4 address of the computer shows the cause (CR21) Info "No IPv4 address" instead of the critical "No default gateway", the error is shown on the computer. Co-Authored-By: Claude Opus 5.5 --- .../Network/NetworkConnectionCheckTests.cs | 2 +- .../ViewModels/NetworkConnectionWidgetViewModel.cs | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs index 3e57fc705b..db6905a3eb 100644 --- a/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs +++ b/Source/NETworkManager.Tests/Network/NetworkConnectionCheckTests.cs @@ -105,7 +105,7 @@ public void GetDNSResult_NothingToResolve() [InlineData("192.168.1.1", true, false, ConnectionState.Warning, ConnectionCheckReason.GatewayNoReply)] // Routed via an adapter without a gateway (e.g. VPN) [InlineData(null, true, false, ConnectionState.Warning, ConnectionCheckReason.NoGateway)] - // No route and no gateway (or no local IP address) + // No route and no gateway [InlineData(null, false, false, ConnectionState.Critical, ConnectionCheckReason.NoGateway)] public void GetGatewayResult(string gateway, bool isRouted, bool isReachable, ConnectionState state, ConnectionCheckReason reason) diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index be5db2cb4a..20fe336a18 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -360,15 +360,20 @@ private void SetScreenshotData() /// Detects the gateway of the local IP address and pings it, see . /// /// Item of the router check (IPv4 or IPv6). - /// Local IP address, or null. + /// Local IP address, or null (IPv4 only, IPv6 is not checked without one). /// The local IP address was detected via the route to the public IP address. /// The gateway, or null if none was found. private static async Task CheckGatewayAsync(ConnectionCheckItem item, IPAddress localIPAddress, bool isRouted) { - var gateway = localIPAddress != null - ? await NetworkInterface.DetectGatewayFromLocalIPAddressAsync(localIPAddress) - : null; + // No local IP address (shown as error on the computer): no gateway to detect + if (localIPAddress == null) + { + item.Complete("-/-", new ConnectionCheckResult(ConnectionState.Info, ConnectionCheckReason.NoIPv4Address)); + return null; + } + + var gateway = await NetworkInterface.DetectGatewayFromLocalIPAddressAsync(localIPAddress); var isReachable = false; From 4d0f93ea32815ee4b780edbe0f8f1f1fa8e26bb2 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:38:11 +0100 Subject: [PATCH 51/56] Fix: Dashboard: Copy disabled for a row without a value (CR22) Co-Authored-By: Claude Opus 5.5 --- Source/NETworkManager/ViewModels/ConnectionCheckItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs b/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs index 7f509248cf..051705a8db 100644 --- a/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs +++ b/Source/NETworkManager/ViewModels/ConnectionCheckItem.cs @@ -208,7 +208,7 @@ public void Complete(string value, ConnectionCheckResult result, string target = /// Gets the command to copy the value. /// public ICommand CopyValueCommand => new RelayCommand(_ => ClipboardHelper.SetClipboard(Value), - _ => !string.IsNullOrEmpty(Value)); + _ => !string.IsNullOrEmpty(Value) && Value != "-/-"); /// /// Gets the command to open the target in another tool (parameter: ). From d0f73d90f41ef827715922d201eaa385abb13904 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:43:33 +0100 Subject: [PATCH 52/56] Fix: Dashboard: No check on a network change while the window is in the tray / minimized (CR23) The dashboard counted as visible and checked at the same time as the status window (twice the pings / API requests). It is marked outdated and checked when the window is shown again (from the tray or restored). Co-Authored-By: Claude Opus 5.5 --- Source/NETworkManager/MainWindow.xaml.cs | 9 +++++- .../Views/DashboardView.xaml.cs | 30 +++++++++++++++---- Website/docs/application/dashboard.md | 2 +- Website/docs/changelog/next-release.md | 2 +- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Source/NETworkManager/MainWindow.xaml.cs b/Source/NETworkManager/MainWindow.xaml.cs index 7aa313d405..d3ea6275e2 100644 --- a/Source/NETworkManager/MainWindow.xaml.cs +++ b/Source/NETworkManager/MainWindow.xaml.cs @@ -1608,7 +1608,11 @@ private void MetroWindowMain_StateChanged(object sender, EventArgs e) } if (WindowState != WindowState.Minimized) + { + // Restored: the dashboard may be outdated (e.g. a network change while minimized) + _dashboardView?.OnMainWindowShown(); return; + } if (SettingsManager.Current.Window_MinimizeToTrayInsteadOfTaskbar) HideWindowToTray(); @@ -1809,6 +1813,9 @@ private void ShowWindowFromTray() Show(); + // The dashboard may be outdated (e.g. a network change while in the tray) + _dashboardView?.OnMainWindowShown(); + _notifyIcon.Visible = SettingsManager.Current.TrayIcon_AlwaysShowIcon; } @@ -1915,7 +1922,7 @@ private void NetworkChangeDispatcherTimer_Tick(object sender, EventArgs e) } // Check the network connection on the dashboard again - _dashboardView?.OnNetworkChanged(); + _dashboardView?.OnNetworkChanged(!_isInTray && WindowState != WindowState.Minimized); // Show status window on network change if (SettingsManager.Current.Status_ShowWindowOnNetworkChange) diff --git a/Source/NETworkManager/Views/DashboardView.xaml.cs b/Source/NETworkManager/Views/DashboardView.xaml.cs index 31ac3812b8..f14d2c0129 100644 --- a/Source/NETworkManager/Views/DashboardView.xaml.cs +++ b/Source/NETworkManager/Views/DashboardView.xaml.cs @@ -59,10 +59,16 @@ public void OnViewVisible() // The widgets may have been shown or hidden in the settings ApplyWidgetSettings(); - // Check the network connection again if something changed, or if the last check is older than the recheck - // interval (e.g. the public IP address may have changed) - not on every switch between the applications - if (_isOutdated || DateTime.Now - _lastCheck >= GlobalStaticConfiguration.Dashboard_RecheckInterval) - CheckNetworkConnection(); + CheckNetworkConnectionIfOutdated(); + } + + /// + /// Called by the main window when it is shown again (from the tray or minimized). + /// + public void OnMainWindowShown() + { + if (_isViewVisible) + CheckNetworkConnectionIfOutdated(); } public void OnViewHide() @@ -75,14 +81,26 @@ public void OnViewHide() /// /// Called by the main window when the network has changed (addresses, adapter connected or disconnected). /// - public void OnNetworkChanged() + /// The main window is shown (not in the tray or minimized). Otherwise the check runs + /// when the window is shown again (the status window checks the network connection meanwhile). + public void OnNetworkChanged(bool isMainWindowShown) { - if (_isViewVisible) + if (_isViewVisible && isMainWindowShown) CheckNetworkConnection(); else _isOutdated = true; } + /// + /// Checks the network connection again if something changed, or if the last check is older than the recheck + /// interval (e.g. the public IP address may have changed) - not on every switch between the applications. + /// + private void CheckNetworkConnectionIfOutdated() + { + if (_isOutdated || DateTime.Now - _lastCheck >= GlobalStaticConfiguration.Dashboard_RecheckInterval) + CheckNetworkConnection(); + } + private void CheckNetworkConnection() { // Hidden or not created yet: checked when it is shown (a changed setting marks the data as outdated, the widget diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index 93430ede9c..b7cab06ced 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -6,7 +6,7 @@ keywords: [NETworkManager, dashboard, network status, network connection, networ # Dashboard -The **Dashboard** shows the status of your computer's current network connection to provide a quick overview of the most important information. Whenever the local network adapter changes state (e.g. an Ethernet cable is plugged in, Wi-Fi or VPN connects), the dashboard checks connectivity to the router and the internet. When you switch back to the dashboard, the network connection is only checked again if the last check is at least 60 seconds old (e.g. the public IP address may have changed) or the network or a setting of the network connection (e.g. the public IP address) has changed in the meantime, so switching between the tools doesn't send a request each time. **F5** or the refresh button always checks again. +The **Dashboard** shows the status of your computer's current network connection to provide a quick overview of the most important information. Whenever the local network adapter changes state (e.g. an Ethernet cable is plugged in, Wi-Fi or VPN connects), the dashboard checks connectivity to the router and the internet. When you switch back to the dashboard (or show the window again from the tray / taskbar), the network connection is only checked again if the last check is at least 60 seconds old (e.g. the public IP address may have changed) or the network or a setting of the network connection (e.g. the public IP address) has changed in the meantime, so switching between the tools doesn't send a request each time. **F5** or the refresh button always checks again. ![Dashboard](../img/dashboard.png) diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index f38faaff99..a2566d0fda 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -154,7 +154,7 @@ Release date: **xx.xx.2026** - Fixed the network connection check getting stuck (all values loading until the next refresh) when it was started several times while a check was running (e.g. the refresh and a network change). The refresh is disabled while a check runs, a network change during a check repeats the check once it has finished. [#PR](PRLINK) - Fixed the network connection widget (dashboard and status window) not updating when **Check public IP address** was changed in the settings until the application was restarted: an old public IP address could be shown as current. [#PR](PRLINK) -- Fixed the network connection not being checked again when the network changed while the dashboard was open (e.g. a cable unplugged or a VPN connected), although the documentation says so. If the dashboard is not open, it is checked when it is opened again. [#PR](PRLINK) +- Fixed the network connection not being checked again when the network changed while the dashboard was open (e.g. a cable unplugged or a VPN connected), although the documentation says so. If the dashboard is not open (or the window is in the tray / minimized, the status window checks meanwhile), it is checked when it is shown again. [#PR](PRLINK) - Fixed the gateway / router not being found (shown as failed although the internet works) for VPN connections whose adapter is not an Ethernet or Wi-Fi adapter (e.g. the Windows VPN client with IKEv2 / SSTP). A VPN adapter without a gateway is no longer shown with the gateway `0.0.0.0`. [#PR](PRLINK) - Fixed an IP address on an error page or the page of a hotspot / captive portal (e.g. hotel Wi-Fi) being shown as the public IP address. The answer of the API must have a success status code, a private IP address is shown as a warning, and an API name that can't be resolved points to the DNS server. The public IPv4 and IPv6 addresses are requested at the same time. [#PR](PRLINK) - Fixed custom public IPv6 address APIs that answer with a JSON object (e.g. `{"ip":"2001:db8::1"}`) not being recognized. A custom API may answer with the IP address as plain text or in a JSON object; other answers (e.g. the HTML page of a captive portal) are no longer searched for an IP address. [#PR](PRLINK) From 6c4aa62ca844c07ac93cc63563d4888275f7f41c Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:43:40 +0100 Subject: [PATCH 53/56] Docs: Dashboard: A running speed test is completed when the widget is hidden (H4) Co-Authored-By: Claude Opus 5.5 --- Website/docs/application/dashboard.md | 2 +- Website/docs/changelog/next-release.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index b7cab06ced..a05e6fc87e 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -129,7 +129,7 @@ Enables or disables the detection of the DNS resolver in use via [`ip-api.com`]( ### Widgets -Show or hide the widgets on the dashboard: **Network connection**, **Speed Test**, **IP geolocation** and **DNS resolver**. A hidden widget doesn't check anything (e.g. no request is sent to `ip-api.com`). If one of IP geolocation and DNS resolver is hidden, the other one uses the whole width. The status window always shows the network connection. +Show or hide the widgets on the dashboard: **Network connection**, **Speed Test**, **IP geolocation** and **DNS resolver**. A hidden widget doesn't check anything (e.g. no request is sent to `ip-api.com`); a speed test that is already running when the widget is hidden is completed. If one of IP geolocation and DNS resolver is hidden, the other one uses the whole width. The status window always shows the network connection. **Type:** `Boolean` diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index a2566d0fda..b663b3e5a7 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -35,7 +35,7 @@ Release date: **xx.xx.2026** **Dashboard** -- The widgets of the dashboard (Network connection, Speed Test, IP geolocation, DNS resolver) can be hidden in the settings (**Settings > Dashboard > Widgets**). A hidden widget doesn't check anything. [#PR](PRLINK) +- The widgets of the dashboard (Network connection, Speed Test, IP geolocation, DNS resolver) can be hidden in the settings (**Settings > Dashboard > Widgets**). A hidden widget doesn't check anything (a running speed test is completed). [#PR](PRLINK) ## Improvements From f418ad699ddb18b3f001cbf95217a1e8d8af53f3 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:53:38 +0100 Subject: [PATCH 54/56] Docs: Dashboard: Remove api.my-ip.io from the public IP address API examples The service no longer answers. The JSON format of the tests stays (relabeled). Co-Authored-By: Claude Opus 5.5 --- .../Network/PublicIPAddressCheckTests.cs | 6 +++--- Website/docs/application/dashboard.md | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs b/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs index 536aa1643d..2216aadeb4 100644 --- a/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs +++ b/Source/NETworkManager.Tests/Network/PublicIPAddressCheckTests.cs @@ -116,18 +116,18 @@ public void GetStatus(string ipAddress, PublicIPAddressCheckStatus expected) // Answer formats of public IP address APIs (examples in the documentation and other common ones), with // documentation addresses. checkip.amazonaws.com: real answer (line break at the end). [Theory] - [InlineData("api.ipify.org, ip4.seeip.org, api.my-ip.io/ip, ifconfig.me/ip", "203.0.113.10", AddressFamily.InterNetwork, "203.0.113.10")] + [InlineData("api.ipify.org, ip4.seeip.org, ifconfig.me/ip", "203.0.113.10", AddressFamily.InterNetwork, "203.0.113.10")] [InlineData("icanhazip.com, ifconfig.co/ip, ipinfo.io/ip, ident.me, checkip.amazonaws.com", "203.0.113.10\n", AddressFamily.InterNetwork, "203.0.113.10")] [InlineData("ip-api.com/line/?fields=query", "203.0.113.10\n", AddressFamily.InterNetwork, "203.0.113.10")] [InlineData("api.ipify.org?format=json, api.seeip.org/jsonip", "{\"ip\":\"203.0.113.10\"}", AddressFamily.InterNetwork, "203.0.113.10")] - [InlineData("api.my-ip.io/v2/ip.json", "{\"success\":true,\"ip\":\"203.0.113.10\",\"type\":\"IPv4\"}", AddressFamily.InterNetwork, "203.0.113.10")] + [InlineData("JSON with other values (e.g. success, type)", "{\"success\":true,\"ip\":\"203.0.113.10\",\"type\":\"IPv4\"}", AddressFamily.InterNetwork, "203.0.113.10")] [InlineData("ip-api.com/json", "{\"status\":\"success\",\"country\":\"Germany\",\"countryCode\":\"DE\",\"region\":\"BE\",\"regionName\":\"Land Berlin\",\"city\":\"Berlin\",\"zip\":\"10115\",\"lat\":52.5,\"lon\":13.4,\"timezone\":\"Europe/Berlin\",\"isp\":\"Example ISP\",\"org\":\"\",\"as\":\"AS64496 Example\",\"query\":\"203.0.113.10\"}", AddressFamily.InterNetwork, "203.0.113.10")] [InlineData("ipinfo.io/json", "{\n \"ip\": \"203.0.113.10\",\n \"hostname\": \"host.example.com\",\n \"city\": \"Berlin\",\n \"loc\": \"52.5244,13.4105\",\n \"readme\": \"https://ipinfo.io/missingauth\"\n}", AddressFamily.InterNetwork, "203.0.113.10")] [InlineData("ifconfig.co/json", "{\n \"ip\": \"203.0.113.10\",\n \"ip_decimal\": 3405803786,\n \"country\": \"Germany\"\n}", AddressFamily.InterNetwork, "203.0.113.10")] [InlineData("api6.ipify.org, v6.ident.me", "2001:db8:85a3::8a2e:370:7334", AddressFamily.InterNetworkV6, "2001:db8:85a3::8a2e:370:7334")] [InlineData("ipv6.icanhazip.com", "2001:db8:85a3::8a2e:370:7334\n", AddressFamily.InterNetworkV6, "2001:db8:85a3::8a2e:370:7334")] [InlineData("api64.ipify.org?format=json", "{\"ip\":\"2001:db8:85a3::8a2e:370:7334\"}", AddressFamily.InterNetworkV6, "2001:db8:85a3::8a2e:370:7334")] - [InlineData("api.my-ip.io/v2/ip.json (IPv6)", "{\"success\":true,\"ip\":\"2001:db8:85a3::8a2e:370:7334\",\"type\":\"IPv6\"}", AddressFamily.InterNetworkV6, "2001:db8:85a3::8a2e:370:7334")] + [InlineData("JSON with other values (IPv6)", "{\"success\":true,\"ip\":\"2001:db8:85a3::8a2e:370:7334\",\"type\":\"IPv6\"}", AddressFamily.InterNetworkV6, "2001:db8:85a3::8a2e:370:7334")] // A dual-stack API answering with IPv6 to the IPv4 request: no valid answer for IPv4 [InlineData("api64.ipify.org (IPv6 answer)", "2001:db8:85a3::8a2e:370:7334", AddressFamily.InterNetwork, null)] // Cloudflare trace (key=value lines, h= is the host, not the client): not supported diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index a05e6fc87e..3532637c36 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -83,7 +83,6 @@ Override the default IPv4 address API to resolve the public IP address. The API | [`https://ifconfig.co/ip`](https://ifconfig.co/ip) | Plain text | | [`https://ipinfo.io/ip`](https://ipinfo.io/ip) | Plain text | | [`https://ip4.seeip.org`](https://ip4.seeip.org/) | Plain text | -| [`https://api.my-ip.io/ip`](https://api.my-ip.io/ip) | Plain text | | [`http://ip-api.com/line/?fields=query`](http://ip-api.com/line/?fields=query) | Plain text (`http` only, 45 requests per minute, non-commercial use only) | Many APIs also return JSON with more information (e.g. `https://ipinfo.io/json`, `https://ifconfig.co/json`, `http://ip-api.com/json`), the first string value that is an IP address is used. An API that returns `key=value` lines (e.g. `https://1.1.1.1/cdn-cgi/trace`) is not supported. From 431c3d2f01f5802fa8a5d2ac3d056b2e0fee36e0 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 23:27:01 +0100 Subject: [PATCH 55/56] Docs: Improve docs --- Source/NETworkManager.Settings/GlobalStaticConfiguration.cs | 2 +- Website/docs/application/dashboard.md | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs b/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs index e309bf3711..814d213686 100644 --- a/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs +++ b/Source/NETworkManager.Settings/GlobalStaticConfiguration.cs @@ -150,7 +150,7 @@ public static class GlobalStaticConfiguration /// public static TimeSpan Dashboard_RecheckInterval => TimeSpan.FromSeconds(60); - // Ping of the gateway and the public IP address (same defaults as the IP Scanner / Port Scanner) + // Ping of the gateway and the public IP address public static int Dashboard_PingTimeout => 2000; public static int Dashboard_PingAttempts => 2; public static int Dashboard_PingBuffer => 32; diff --git a/Website/docs/application/dashboard.md b/Website/docs/application/dashboard.md index 3532637c36..acf4f598d8 100644 --- a/Website/docs/application/dashboard.md +++ b/Website/docs/application/dashboard.md @@ -82,7 +82,6 @@ Override the default IPv4 address API to resolve the public IP address. The API | [`https://checkip.amazonaws.com`](https://checkip.amazonaws.com/) | Plain text | | [`https://ifconfig.co/ip`](https://ifconfig.co/ip) | Plain text | | [`https://ipinfo.io/ip`](https://ipinfo.io/ip) | Plain text | -| [`https://ip4.seeip.org`](https://ip4.seeip.org/) | Plain text | | [`http://ip-api.com/line/?fields=query`](http://ip-api.com/line/?fields=query) | Plain text (`http` only, 45 requests per minute, non-commercial use only) | Many APIs also return JSON with more information (e.g. `https://ipinfo.io/json`, `https://ifconfig.co/json`, `http://ip-api.com/json`), the first string value that is an IP address is used. An API that returns `key=value` lines (e.g. `https://1.1.1.1/cdn-cgi/trace`) is not supported. @@ -101,8 +100,6 @@ Override the default IPv6 address API to resolve the public IP address. The API |-----|--------| | [`https://api6.ipify.org`](https://api6.ipify.org/) | Plain text | | [`https://api64.ipify.org?format=json`](https://api64.ipify.org?format=json) | JSON `{"ip":"xxxx:xx:xxx::xx"}` (IPv6 if available, otherwise IPv4 - then the answer is not accepted) | -| [`https://ipv6.icanhazip.com`](https://ipv6.icanhazip.com/) | Plain text | -| [`https://v6.ident.me`](https://v6.ident.me/) | Plain text | ### Check IP geolocation From 78be5a03819e55c3cf28cb10352e87cb4f6b9295 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Wed, 25 Nov 2026 23:28:42 +0100 Subject: [PATCH 56/56] Update next-release.md --- Website/docs/changelog/next-release.md | 50 +++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index b663b3e5a7..16649903eb 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -21,7 +21,7 @@ Release date: **xx.xx.2026** **Dashboard** -- A custom public IP address API (**Settings > Dashboard**) must return the IP address as plain text or in a JSON object (e.g. `{"ip":"xx.xx.xx.xx"}`). An address inside other text or an HTML page (e.g. `checkip.dyndns.org`) is no longer used, because the page of a hotspot / captive portal could be shown as the public IP address. See the [examples](../application/dashboard.md#use-custom-ipv4-address-api). [#PR](PRLINK) +- A custom public IP address API (**Settings > Dashboard**) must return the IP address as plain text or in a JSON object (e.g. `{"ip":"xx.xx.xx.xx"}`). An address inside other text or an HTML page (e.g. `checkip.dyndns.org`) is no longer used, because the page of a hotspot / captive portal could be shown as the public IP address. See the [examples](../application/dashboard.md#use-custom-ipv4-address-api). [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) ## What's new? @@ -35,7 +35,7 @@ Release date: **xx.xx.2026** **Dashboard** -- The widgets of the dashboard (Network connection, Speed Test, IP geolocation, DNS resolver) can be hidden in the settings (**Settings > Dashboard > Widgets**). A hidden widget doesn't check anything (a running speed test is completed). [#PR](PRLINK) +- The widgets of the dashboard (Network connection, Speed Test, IP geolocation, DNS resolver) can be hidden in the settings (**Settings > Dashboard > Widgets**). A hidden widget doesn't check anything (a running speed test is completed). [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) ## Improvements @@ -59,24 +59,24 @@ Release date: **xx.xx.2026** **Dashboard** -- Switching back to the dashboard checks the network connection only if the last check is at least 60 seconds old (or the network / a setting of the network connection changed), instead of on every switch between the tools. **F5** and the refresh button always check. [#PR](PRLINK) -- The network connection check is faster (also at startup and in the status window): the local IP address and the gateway are read directly from the network adapters instead of querying all adapter details incl. PowerShell up to four times per check. This also speeds up the detection of the local IP address in the **IP Scanner** when no route is available. [#PR](PRLINK) -- The network connection shows a warning instead of OK if the computer has only a link-local IPv4 address (`169.254.x.x`, no address from a DHCP server) or no route to the internet. Without an IPv6 connection (e.g. the internet provider doesn't support IPv6), the IPv6 values are shown as information (gray) instead of failed (red), and the IPv6 address of the router and the internet are not checked. Hover over an icon to see the reason. [#PR](PRLINK) -- The DNS name (PTR) of the IPv6 address is no longer requested after the DNS server failed for the IPv4 address (the same server would time out again), so the network connection check finishes faster without a working DNS server. Without an IP address to resolve, the DNS value is shown as information instead of failed. [#PR](PRLINK) -- The gateway / router is now pinged (2 attempts, 2 seconds timeout) instead of only checking that a gateway is configured. No reply is shown as a warning (some routers block ICMP). A network adapter without a gateway (e.g. a VPN connection) is shown as a warning instead of failed if the internet is routed via it. [#PR](PRLINK) -- The internet is now checked with a ping of the public IPv4 / IPv6 address (settings, `1.1.1.1` / `2606:4700:4700::1111`), the public IP address API and the internet connectivity reported by Windows. A hotspot / captive portal that requires a sign-in, a blocked public IP address API (e.g. a proxy) or blocked ICMP are shown as a warning instead of the internet being not reachable. With **Check public IP address** disabled, the internet is still checked (ping and Windows) instead of showing "Check is disabled!". [#PR](PRLINK) -- The values of the network connection (dashboard and status window) can be opened in other tools via the context menu: Port Scanner, Ping Monitor, Traceroute and DNS Lookup, the gateway / router also in the Web Console, the public IP address also in RDAP and IP Geolocation. **Copy** copies the whole value. Opening a tool from the status window shows the main window. [#PR](PRLINK) -- A value of the network connection that is cut off in a narrow window (e.g. a long IPv6 address or DNS name) is shown completely in the tooltip. [#PR](PRLINK) -- The network connection shows the time of the last check ("Reloaded at ...") next to the refresh button, like other tools. [#PR](PRLINK) -- New **Copy all** button in the network connection: copies all values with the reasons of the states as text, e.g. for a support request. [#PR](PRLINK) +- Switching back to the dashboard checks the network connection only if the last check is at least 60 seconds old (or the network / a setting of the network connection changed), instead of on every switch between the tools. **F5** and the refresh button always check. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- The network connection check is faster (also at startup and in the status window): the local IP address and the gateway are read directly from the network adapters instead of querying all adapter details incl. PowerShell up to four times per check. This also speeds up the detection of the local IP address in the **IP Scanner** when no route is available. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- The network connection shows a warning instead of OK if the computer has only a link-local IPv4 address (`169.254.x.x`, no address from a DHCP server) or no route to the internet. Without an IPv6 connection (e.g. the internet provider doesn't support IPv6), the IPv6 values are shown as information (gray) instead of failed (red), and the IPv6 address of the router and the internet are not checked. Hover over an icon to see the reason. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- The DNS name (PTR) of the IPv6 address is no longer requested after the DNS server failed for the IPv4 address (the same server would time out again), so the network connection check finishes faster without a working DNS server. Without an IP address to resolve, the DNS value is shown as information instead of failed. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- The gateway / router is now pinged (2 attempts, 2 seconds timeout) instead of only checking that a gateway is configured. No reply is shown as a warning (some routers block ICMP). A network adapter without a gateway (e.g. a VPN connection) is shown as a warning instead of failed if the internet is routed via it. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- The internet is now checked with a ping of the public IPv4 / IPv6 address (settings, `1.1.1.1` / `2606:4700:4700::1111`), the public IP address API and the internet connectivity reported by Windows. A hotspot / captive portal that requires a sign-in, a blocked public IP address API (e.g. a proxy) or blocked ICMP are shown as a warning instead of the internet being not reachable. With **Check public IP address** disabled, the internet is still checked (ping and Windows) instead of showing "Check is disabled!". [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- The values of the network connection (dashboard and status window) can be opened in other tools via the context menu: Port Scanner, Ping Monitor, Traceroute and DNS Lookup, the gateway / router also in the Web Console, the public IP address also in RDAP and IP Geolocation. **Copy** copies the whole value. Opening a tool from the status window shows the main window. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- A value of the network connection that is cut off in a narrow window (e.g. a long IPv6 address or DNS name) is shown completely in the tooltip. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- The network connection shows the time of the last check ("Reloaded at ...") next to the refresh button, like other tools. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- New **Copy all** button in the network connection: copies all values with the reasons of the states as text, e.g. for a support request. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) **Status window** -- The countdown of the status window moves smoothly (like the progress of the IP Scanner) instead of in small steps, and the window no longer grows and moves right after it was opened on a network change. [#PR](PRLINK) +- The countdown of the status window moves smoothly (like the progress of the IP Scanner) instead of in small steps, and the window no longer grows and moves right after it was opened on a network change. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) **Notifications** -- The countdown of the notifications (e.g. Ping Monitor, IP Scanner) moves smoothly, like the progress of the IP Scanner, instead of in small steps. [#PR](PRLINK) +- The countdown of the notifications (e.g. Ping Monitor, IP Scanner) moves smoothly, like the progress of the IP Scanner, instead of in small steps. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) ## Bug Fixes @@ -152,20 +152,20 @@ Release date: **xx.xx.2026** **Dashboard** -- Fixed the network connection check getting stuck (all values loading until the next refresh) when it was started several times while a check was running (e.g. the refresh and a network change). The refresh is disabled while a check runs, a network change during a check repeats the check once it has finished. [#PR](PRLINK) -- Fixed the network connection widget (dashboard and status window) not updating when **Check public IP address** was changed in the settings until the application was restarted: an old public IP address could be shown as current. [#PR](PRLINK) -- Fixed the network connection not being checked again when the network changed while the dashboard was open (e.g. a cable unplugged or a VPN connected), although the documentation says so. If the dashboard is not open (or the window is in the tray / minimized, the status window checks meanwhile), it is checked when it is shown again. [#PR](PRLINK) -- Fixed the gateway / router not being found (shown as failed although the internet works) for VPN connections whose adapter is not an Ethernet or Wi-Fi adapter (e.g. the Windows VPN client with IKEv2 / SSTP). A VPN adapter without a gateway is no longer shown with the gateway `0.0.0.0`. [#PR](PRLINK) -- Fixed an IP address on an error page or the page of a hotspot / captive portal (e.g. hotel Wi-Fi) being shown as the public IP address. The answer of the API must have a success status code, a private IP address is shown as a warning, and an API name that can't be resolved points to the DNS server. The public IPv4 and IPv6 addresses are requested at the same time. [#PR](PRLINK) -- Fixed custom public IPv6 address APIs that answer with a JSON object (e.g. `{"ip":"2001:db8::1"}`) not being recognized. A custom API may answer with the IP address as plain text or in a JSON object; other answers (e.g. the HTML page of a captive portal) are no longer searched for an IP address. [#PR](PRLINK) +- Fixed the network connection check getting stuck (all values loading until the next refresh) when it was started several times while a check was running (e.g. the refresh and a network change). The refresh is disabled while a check runs, a network change during a check repeats the check once it has finished. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- Fixed the network connection widget (dashboard and status window) not updating when **Check public IP address** was changed in the settings until the application was restarted: an old public IP address could be shown as current. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- Fixed the network connection not being checked again when the network changed while the dashboard was open (e.g. a cable unplugged or a VPN connected), although the documentation says so. If the dashboard is not open (or the window is in the tray / minimized, the status window checks meanwhile), it is checked when it is shown again. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- Fixed the gateway / router not being found (shown as failed although the internet works) for VPN connections whose adapter is not an Ethernet or Wi-Fi adapter (e.g. the Windows VPN client with IKEv2 / SSTP). A VPN adapter without a gateway is no longer shown with the gateway `0.0.0.0`. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- Fixed an IP address on an error page or the page of a hotspot / captive portal (e.g. hotel Wi-Fi) being shown as the public IP address. The answer of the API must have a success status code, a private IP address is shown as a warning, and an API name that can't be resolved points to the DNS server. The public IPv4 and IPv6 addresses are requested at the same time. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- Fixed custom public IPv6 address APIs that answer with a JSON object (e.g. `{"ip":"2001:db8::1"}`) not being recognized. A custom API may answer with the IP address as plain text or in a JSON object; other answers (e.g. the HTML page of a captive portal) are no longer searched for an IP address. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) **Status window** -- The status window now opens after a network change once the network has settled (5 seconds without further changes, e.g. after the DHCP address was assigned, at most 20 seconds after the first change) instead of 5 seconds after the first change, so it no longer shows an intermediate state. An error while updating the DNS configuration after a network change no longer stops the detection of further network changes. [#PR](PRLINK) -- The status window that opens on a network change no longer takes the keyboard focus from the application you are working in. Clicking into it keeps it open (the countdown stops). [#PR](PRLINK) -- Fixed the status window being hidden right after it was opened from the tray icon when the countdown of a previous network change had just ended. [#PR](PRLINK) -- Fixed the status window being cut off on the left on small screens (e.g. 1280 x 720 with 150 % scaling). It is no longer wider than the screen. [#PR](PRLINK) -- Fixed the status window opened by the user (e.g. from the tray icon) closing itself after a network change. It stays open and checks the network connection again. [#PR](PRLINK) +- The status window now opens after a network change once the network has settled (5 seconds without further changes, e.g. after the DHCP address was assigned, at most 20 seconds after the first change) instead of 5 seconds after the first change, so it no longer shows an intermediate state. An error while updating the DNS configuration after a network change no longer stops the detection of further network changes. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- The status window that opens on a network change no longer takes the keyboard focus from the application you are working in. Clicking into it keeps it open (the countdown stops). [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- Fixed the status window being hidden right after it was opened from the tray icon when the countdown of a previous network change had just ended. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- Fixed the status window being cut off on the left on small screens (e.g. 1280 x 720 with 150 % scaling). It is no longer wider than the screen. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) +- Fixed the status window opened by the user (e.g. from the tray icon) closing itself after a network change. It stays open and checks the network connection again. [#3734](https://github.com/BornToBeRoot/NETworkManager/pull/3734) ## Dependencies, Refactoring & Documentation