Skip to content

Commit 5efee54

Browse files
authored
Feature: Add fallback ip detection (#3296)
* Feature: Add fallback ip detection * Update NetworkConnectionWidgetViewModel.cs * Docs: #3296 * Update Dragablz
1 parent 51df9a7 commit 5efee54

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

Source/3rdparty/Dragablz

Submodule Dragablz updated 64 files

Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Windows.Input;
1111
using log4net;
1212
using NetworkInterface = NETworkManager.Models.Network.NetworkInterface;
13+
using System.Net.Sockets;
1314

1415
namespace NETworkManager.ViewModels;
1516

@@ -760,6 +761,14 @@ private Task CheckConnectionComputerAsync(CancellationToken ct)
760761
await NetworkInterface.DetectLocalIPAddressBasedOnRoutingAsync(
761762
IPAddress.Parse(SettingsManager.Current.Dashboard_PublicIPv4Address));
762763

764+
if (detectedLocalIPv4Address == null)
765+
{
766+
Log.Debug("CheckConnectionComputerAsync - Local IPv4 address detection via routing failed, trying network interfaces...");
767+
768+
detectedLocalIPv4Address = await NetworkInterface.DetectLocalIPAddressFromNetworkInterfaceAsync(
769+
AddressFamily.InterNetwork);
770+
}
771+
763772
if (detectedLocalIPv4Address != null)
764773
{
765774
Log.Debug("CheckConnectionComputerAsync - Local IPv4 address detected: " + detectedLocalIPv4Address);
@@ -787,6 +796,14 @@ await NetworkInterface.DetectLocalIPAddressBasedOnRoutingAsync(
787796
await NetworkInterface.DetectLocalIPAddressBasedOnRoutingAsync(
788797
IPAddress.Parse(SettingsManager.Current.Dashboard_PublicIPv6Address));
789798

799+
if (detectedLocalIPv6Address == null)
800+
{
801+
Log.Debug("CheckConnectionComputerAsync - Local IPv6 address detection via routing failed, trying network interfaces...");
802+
803+
detectedLocalIPv6Address = await NetworkInterface.DetectLocalIPAddressFromNetworkInterfaceAsync(
804+
AddressFamily.InterNetworkV6);
805+
}
806+
790807
if (detectedLocalIPv6Address != null)
791808
{
792809
Log.Debug("CheckConnectionComputerAsync - Local IPv6 address detected: " + detectedLocalIPv6Address);
@@ -896,6 +913,9 @@ private Task CheckConnectionRouterAsync(CancellationToken ct)
896913
await NetworkInterface.DetectLocalIPAddressBasedOnRoutingAsync(
897914
IPAddress.Parse(SettingsManager.Current.Dashboard_PublicIPv4Address));
898915

916+
detectedLocalIPv4Address ??= await NetworkInterface.DetectLocalIPAddressFromNetworkInterfaceAsync(
917+
AddressFamily.InterNetwork);
918+
899919
if (detectedLocalIPv4Address != null)
900920
{
901921
Log.Debug("CheckConnectionRouterAsync - Computer IPv4 address detected: " + detectedLocalIPv4Address);
@@ -939,6 +959,9 @@ await NetworkInterface.DetectGatewayFromLocalIPAddressAsync(
939959
await NetworkInterface.DetectLocalIPAddressBasedOnRoutingAsync(
940960
IPAddress.Parse(SettingsManager.Current.Dashboard_PublicIPv6Address));
941961

962+
detectedComputerIPv6 ??= await NetworkInterface.DetectLocalIPAddressFromNetworkInterfaceAsync(
963+
AddressFamily.InterNetworkV6);
964+
942965
if (detectedComputerIPv6 != null)
943966
{
944967
Log.Debug("CheckConnectionRouterAsync - Computer IPv6 address detected: " + detectedComputerIPv6);

Website/docs/changelog/next-release.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ Release date: **xx.xx.2025**
5656
- Settings format migrated from `XML` to `JSON`. The settings file will be automatically converted on first start after the update. [#3282](https://github.com/BornToBeRoot/NETworkManager/pull/3282)
5757
- Create a daily backup of the settings file before saving changes. Up to `10` backup files are kept in the `Backups` subfolder of the settings directory. [#3283](https://github.com/BornToBeRoot/NETworkManager/pull/3283)
5858

59+
**Dashboard**
60+
61+
- Enhance local IP detection logic: If local IP cannot be determined via routing, now iterates over active network adapters and selects the first valid IPv4/IPv6 address (with link-local addresses (`169.254.x.x`, `fe80::..`) given lower priority). [#3296](https://github.com/BornToBeRoot/NETworkManager/pull/3296)
62+
5963
**IP Scanner**
6064

6165
- Improved local subnet detection: If local IP cannot be determined via routing, now iterates over active network adapters and selects the first valid IPv4 address (with link-local addresses (`169.254.x.x`) given lower priority). [#3288](https://github.com/BornToBeRoot/NETworkManager/pull/3288)

0 commit comments

Comments
 (0)