Skip to content

Fix dns_apply_windows build errors in adapter lookup; adapter discovery & UI improvements#2

Open
Abhijrathod wants to merge 1 commit into
codex5.3from
codex/add-more-features-to-application-a9ajru
Open

Fix dns_apply_windows build errors in adapter lookup; adapter discovery & UI improvements#2
Abhijrathod wants to merge 1 commit into
codex5.3from
codex/add-more-features-to-application-a9ajru

Conversation

@Abhijrathod

Copy link
Copy Markdown
Owner

Motivation

  • Resolve compilation failures caused by missing Windows networking symbols and inconsistent include ordering in cpp_core/src/dns_apply_windows.cpp.
  • Preserve and improve adapter discovery so disabled/disconnected adapters remain visible to the UI while prioritizing connected adapters.
  • Improve UX clarity by surfacing adapter state, DNS summaries, and a visible app version in the UI.

Description

  • Fixed include ordering and portability in cpp_core/src/dns_apply_windows.cpp by adding #define WIN32_LEAN_AND_MEAN and including winsock2.h/ws2tcpip.h before windows.h, and replaced GAA_FLAG_INCLUDE_PREFIX with 0 in GetAdaptersAddresses calls to avoid SDK-dependent symbol issues while keeping adapter enumeration logic.
  • Implemented NormalizeGuid + FindAdapterFriendlyName helpers and use adapter friendly name (when available) as a netsh selector and updated netsh commands to use interface ipv4 set dnsservers / add dnsservers / source=dhcp syntax for more reliable execution.
  • Adjusted cpp_core/src/network_windows.cpp to skip only loopback adapters so disabled/disconnected adapters remain visible to the UI.
  • Updated UI and viewmodel: added AdapterState and DnsSummary properties in windows_gui/Models/NetworkModel.cs, showed a version badge and helper text in windows_gui/MainWindow.xaml, and changed selection/guardrail logic in windows_gui/ViewModels/MainViewModel.cs to prefer connected adapters and prevent apply/restore on disabled adapters.
  • Bumped WPF project metadata version fields in windows_gui/DNSChanger.csproj and added a short release note in README.md under Latest changes (v2.1.0).

Testing

  • Ran static inspections and pattern checks such as rg -n "GAA_FLAG_INCLUDE_PREFIX|GetAdaptersAddresses|winsock2" and inspected the modified file with nl to verify the include/order and flag changes succeeded.
  • Confirmed the GetAdaptersAddresses calls no longer reference the undefined macro and that adapter-friendly-name lookup code is present by file inspection.
  • A full Windows/MSVC build and WPF dotnet build were not executed in this environment due to the container/tooling limitations, so no end-to-end binary build was produced here.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +361 to +364
if (!SelectedNetwork.IsEnabled)
{
UiService.ShowError($"{SelectedNetwork.Name} is disabled. Enable the adapter and try again.");
StatusMessage = "Selected adapter is disabled";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant