fix(sync): prefer gateway-backed LAN interfaces on Windows#247
Merged
Conversation
…ay and metric support Enhance network interface detection to prioritize interfaces based on gateway availability and interface metrics. Adds new fields to NetworkInterfaceInfo (hasDefaultGateway, interfaceMetric, isVirtual, gatewayIp), implements Windows-specific metadata retrieval via PowerShell, and refactors priority calculation to prefer physical interfaces with active gateways over virtual adapters. Exposes sorted results via new getPreferredIPAddresses() method.
…ndling and testability - Add timeout (10s) to Windows metadata PowerShell query to prevent hanging - Add error IDs for all error logging points for better debugging - Include hasDefaultGateway, interfaceMetric, isVirtual, and gatewayIp in NetworkInterfaceInfo equality - Refactor _calculatePriority to use isVirtual parameter instead of parsing name - Add @VisibleForTesting wrappers for priority calculation, virtual interface detection, and Windows metadata resolution - Add comprehensive tests for priority calculation, virtual interface detection, and metadata resolution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Windows sync server address selection where WHPH could advertise a Hyper-V/virtual adapter IP (e.g.
172.31.x.x) instead of a LAN-reachable adapter.This change makes interface selection route-aware and gateway-aware so pairing details prefer adapters that are actually reachable from the local network.
Closes #246.
What Changed
NetworkInterfaceInfowith metadata used for smarter ranking:hasDefaultGatewayinterfaceMetricisVirtualgatewayIpNetworkInterfaceService:Get-NetIPConfiguration,Get-NetIPInterface)NetworkUtils.getLocalIpAddresses()now delegates togetPreferredIPAddresses()172.xhandlingValidation
fvm flutter test test/core/application/features/sync/services/network_interface_service_test.dartfvm flutter analyze lib/core/application/features/sync/services/network_interface_service.dart lib/core/application/features/sync/services/abstraction/i_network_interface_service.dart lib/presentation/ui/shared/utils/network_utils.dart lib/presentation/ui/features/sync/components/sync_connect_info_dialog.dart