Fix dns_apply_windows build errors in adapter lookup; adapter discovery & UI improvements#2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ce9c3f8a6c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!SelectedNetwork.IsEnabled) | ||
| { | ||
| UiService.ShowError($"{SelectedNetwork.Name} is disabled. Enable the adapter and try again."); | ||
| StatusMessage = "Selected adapter is disabled"; |
There was a problem hiding this comment.
Distinguish disabled adapters from disconnected ones
This new guard blocks DNS changes for every network where IsEnabled is false, but in cpp_core/src/network_windows.cpp both isEnabled and isConnected are derived from adapter->OperStatus == IfOperStatusUp. In practice, enabled-but-disconnected adapters (for example an unplugged Ethernet NIC) report OperStatus down, so they are mislabeled as disabled and users are prevented from apply/restore operations even though the change is intended to block only truly disabled adapters.
Useful? React with 👍 / 👎.
Motivation
cpp_core/src/dns_apply_windows.cpp.Description
cpp_core/src/dns_apply_windows.cppby adding#define WIN32_LEAN_AND_MEANand includingwinsock2.h/ws2tcpip.hbeforewindows.h, and replacedGAA_FLAG_INCLUDE_PREFIXwith0inGetAdaptersAddressescalls to avoid SDK-dependent symbol issues while keeping adapter enumeration logic.NormalizeGuid+FindAdapterFriendlyNamehelpers and use adapter friendly name (when available) as anetshselector and updatednetshcommands to useinterface ipv4 set dnsservers/add dnsservers/source=dhcpsyntax for more reliable execution.cpp_core/src/network_windows.cppto skip only loopback adapters so disabled/disconnected adapters remain visible to the UI.AdapterStateandDnsSummaryproperties inwindows_gui/Models/NetworkModel.cs, showed a version badge and helper text inwindows_gui/MainWindow.xaml, and changed selection/guardrail logic inwindows_gui/ViewModels/MainViewModel.csto prefer connected adapters and prevent apply/restore on disabled adapters.windows_gui/DNSChanger.csprojand added a short release note inREADME.mdunderLatest changes (v2.1.0).Testing
rg -n "GAA_FLAG_INCLUDE_PREFIX|GetAdaptersAddresses|winsock2"and inspected the modified file withnlto verify the include/order and flag changes succeeded.GetAdaptersAddressescalls no longer reference the undefined macro and that adapter-friendly-name lookup code is present by file inspection.dotnet buildwere not executed in this environment due to the container/tooling limitations, so no end-to-end binary build was produced here.Codex Task