Skip to content

Add DNS-over-HTTPS (DoH) support - #4856

Merged
ChrisTitusTech merged 10 commits into
ChrisTitusTech:mainfrom
mewclouds:feat/add-doh-to-dns
Jul 28, 2026
Merged

Add DNS-over-HTTPS (DoH) support#4856
ChrisTitusTech merged 10 commits into
ChrisTitusTech:mainfrom
mewclouds:feat/add-doh-to-dns

Conversation

@mewclouds

Copy link
Copy Markdown
Contributor

Type of Change

  • New feature
  • Bug fix
  • Documentation update
  • Refactor
  • UI/UX improvement

Description

This PR introduces DNS-over-HTTPS (DoH) support as a transparent, encrypted-by-default security enhancement to the DNS configuration workflow for Windows 11 and forward.

Key Changes

  1. Config Additions (dns.json):
    • Added "DohTemplate" keys containing HTTPS URLs for all DNS providers in dns.json
  2. Strict DoH Enforcement (Set-WinUtilDNS.ps1):
    • Automatically detects if the target OS supports the Add-DnsClientDohServerAddress cmdlet.
    • If supported and configured, registers the DoH server templates globally with auto-upgrade enabled and fallback disabled (-AllowFallbackToUdp $false).
    • Enforces interface-level DNS encryption by setting the DohFlags registry value to 1 (strict) under HKLM:\System\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\<InterfaceGuid>\DohInterfaceSettings.
  3. DHCP Registry Cleanup:
    • Automatically cleans up the DohInterfaceSettings registry tree recursively when resetting adapter DNS configurations back to DHCP, preventing registry bloat.
  4. Mocked Unit Tests (dns.Tests.ps1):
    • Mocked all new DoH cmdlets and registry operations in Pester to verify correct configuration and cleanup without altering the local host environment.

Validation

  • Unit Testing: All Pester test suites passed successfully (Invoke-Pester).
  • Compilation: Ran .\Compile.ps1 to successfully compile the source modifications into the release artifact.
  • Manual Verification: Run .\winutil.ps1 and verified that choosing any of the DNS options successfully forces encrypted connections.
  • Check Style: Verified code hygiene with git diff --check.
  • System Indicator: Wi-Fi/Ethernet properties show the DNS settings with the Windows native (Encrypted) indicator:
image

Issue related to PR

  • Resolves #

@github-actions github-actions Bot added the new feature New feature or request label Jul 17, 2026

@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: 1786067fcf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread config/dns.json Outdated
Comment thread functions/private/Set-WinUtilDNS.ps1 Outdated
@mewclouds

Copy link
Copy Markdown
Contributor Author

@codex review latest changes

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 3742fef042

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@mewclouds

Copy link
Copy Markdown
Contributor Author

I realized this change makes a broader product decision by enabling DoH for all supported DNS configurations, and I did not confirm that behavior with Titus beforehand. I’m happy to adjust this to be optional (i.e., having Cloudflare and Cloudflare (DoH)), scope it differently, or move the design discussion into a feature request if that would be preferable.

@ChrisTitusTech

Copy link
Copy Markdown
Owner

@codex review

@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: 7a0adc802e

ℹ️ 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 thread functions/private/Set-WinUtilDNS.ps1 Outdated
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added DNS-over-HTTPS (DoH) support on compatible systems by allowing each DNS provider to specify a DoH endpoint.
    • Automatically configures DoH for supported providers and applies per-interface DoH settings when using non-DHCP DNS.
  • Bug Fixes
    • Updates existing DoH entries when found, avoiding duplicates.
    • Clears the DNS client cache only when switching away from DHCP with DoH enabled.
    • DHCP mode now removes custom per-interface DoH settings.
  • Tests
    • Expanded the DNS test suite to validate DoH provisioning, update behavior, and DHCP cleanup paths.

Walkthrough

DNS provider configurations now include DNS-over-HTTPS templates. Set-WinUtilDNS applies DoH settings per adapter, updates registry state, clears the cache, and removes DoH settings when reverting to DHCP. Pester tests cover these flows.

Changes

DNS-over-HTTPS configuration

Layer / File(s) Summary
Provider DoH templates
config/dns.json
Adds DohTemplate endpoint values to eight DNS provider configurations.
Adapter DoH application
functions/private/Set-WinUtilDNS.ps1
Detects DoH support, adds or updates DoH server entries, writes interface registry settings, clears the DNS cache, removes DoH settings for DHCP, and updates error messages.
DoH behavior validation
pester/dns.Tests.ps1
Mocks DoH commands and registry operations, and verifies DoH creation, updates, cache clearing, DHCP cleanup, and revised failure output.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SetWinUtilDNS
  participant DNSProviderConfig
  participant WindowsDoH
  participant DoHRegistry
  participant DNSClientCache
  SetWinUtilDNS->>DNSProviderConfig: read DNS addresses and DohTemplate
  SetWinUtilDNS->>WindowsDoH: add or update DoH server entries
  SetWinUtilDNS->>DoHRegistry: write per-interface DohFlags
  SetWinUtilDNS->>DNSClientCache: clear cache
Loading

Suggested reviewers: christitustech

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding DNS-over-HTTPS support.
Description check ✅ Passed The description is directly about the DoH DNS changes and matches the files updated.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@functions/private/Set-WinUtilDNS.ps1`:
- Around line 61-65: Enable DoH auto-upgrade by changing the -AutoUpgrade
argument to $true in both Set-DnsClientDohServerAddress and
Add-DnsClientDohServerAddress within functions/private/Set-WinUtilDNS.ps1 lines
61-65. Update the corresponding Pester expectation in pester/dns.Tests.ps1 lines
103-126 to assert $true.
- Around line 62-80: Update the DoH registration flow around
Set-DnsClientDohServerAddress and Add-DnsClientDohServerAddress to use
terminating error behavior so failures reach the surrounding catch instead of
being suppressed. Also make the New-Item and New-ItemProperty registry writes
terminating, ensuring completion/logging and subsequent DNS cache handling occur
only after every DoH setup step succeeds.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b9071f8d-0c61-4a38-8096-4b0921fb1014

📥 Commits

Reviewing files that changed from the base of the PR and between 50be739 and af55b28.

📒 Files selected for processing (3)
  • config/dns.json
  • functions/private/Set-WinUtilDNS.ps1
  • pester/dns.Tests.ps1

Comment thread functions/private/Set-WinUtilDNS.ps1 Outdated
Comment thread functions/private/Set-WinUtilDNS.ps1 Outdated
@mewclouds

Copy link
Copy Markdown
Contributor Author

@codex review

@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: b7af9c0988

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread functions/private/Set-WinUtilDNS.ps1
Comment thread functions/private/Set-WinUtilDNS.ps1 Outdated
Comment thread functions/private/Set-WinUtilDNS.ps1
@mewclouds

Copy link
Copy Markdown
Contributor Author

@ChrisTitusTech The latest review identified three behavior decisions around DHCP and DoH cleanup: global auto-upgrade entries may persist after switching to DHCP, cleanup currently removes the whole per-interface DoH tree, and a failed DoH setup can leave the adapter on plaintext DNS. Should WinUtil remove only DoH state it created, preserve existing settings, and roll back DNS changes if DoH setup fails? I’d prefer guidance before making these broader changes

@ChrisTitusTech

Copy link
Copy Markdown
Owner

Yes, I'd say remove DoH state it created on failure and preserve existing settings.

Resolved the messages for the 2 bad recommendations the one revert on dhcp is a good recommend.

@mewclouds

Copy link
Copy Markdown
Contributor Author

Yes, I'd say remove DoH state it created on failure and preserve existing settings.

Resolved the messages for the 2 bad recommendations the one revert on dhcp is a good recommend.

Thank you! Done.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
functions/private/Set-WinUtilDNS.ps1 (1)

94-96: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Flush the DNS cache after every transition. DHCP resets and static changes without DoH support skip Clear-DnsClientCache, so stale answers can persist until TTL expiry.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@functions/private/Set-WinUtilDNS.ps1` around lines 94 - 96, Update the DNS
transition flow in Set-WinUtilDNS so Clear-DnsClientCache runs after every DHCP
reset or static DNS change, regardless of DoH support or DohTemplate
availability. Remove the current DoH-specific condition while preserving the
existing transition behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@functions/private/Set-WinUtilDNS.ps1`:
- Around line 49-64: Track ownership of DoH registrations in Set-WinUtilDNS
before mutating the system-wide server-address list: at lines 49-64, remove only
entries created by WinUtil or persist and restore prior values instead of
deleting by address; at lines 75-89, avoid changing pre-existing registrations
unless their original templates and flags are captured and restored. Apply the
ownership tracking consistently across both sites.

---

Outside diff comments:
In `@functions/private/Set-WinUtilDNS.ps1`:
- Around line 94-96: Update the DNS transition flow in Set-WinUtilDNS so
Clear-DnsClientCache runs after every DHCP reset or static DNS change,
regardless of DoH support or DohTemplate availability. Remove the current
DoH-specific condition while preserving the existing transition behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1029d039-3f2e-4b83-89c3-9264cc5d185a

📥 Commits

Reviewing files that changed from the base of the PR and between b7af9c0 and 962d5b6.

📒 Files selected for processing (2)
  • functions/private/Set-WinUtilDNS.ps1
  • pester/dns.Tests.ps1
🚧 Files skipped from review as they are similar to previous changes (1)
  • pester/dns.Tests.ps1

Comment thread functions/private/Set-WinUtilDNS.ps1
@ChrisTitusTech
ChrisTitusTech merged commit d790118 into ChrisTitusTech:main Jul 28, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants