Skip to content

Implement RFC6761 reserved DNS names handling#6924

Merged
rzikm merged 3 commits intomainfrom
reserved-domain-names
Mar 10, 2026
Merged

Implement RFC6761 reserved DNS names handling#6924
rzikm merged 3 commits intomainfrom
reserved-domain-names

Conversation

@rzikm
Copy link
Copy Markdown
Member

@rzikm rzikm commented Oct 15, 2025

Replaces microsoft/aspire#10311 since the code moved to this repo.

The Managed DNS implementation correctly special-cased "localhost" and resolved to loopback without contacting DNS server, but the authoritative RFC 6761 requires the same for subdomains as well (e.g. service.localhost). Ths PR fills the gap, including the other special-cased name "invalid".

Copilot AI review requested due to automatic review settings October 15, 2025 11:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements RFC 6761 compliant handling of reserved DNS names by extending special-case treatment beyond just "localhost" to include its subdomains (e.g., "service.localhost") and the "invalid" domain. The implementation centralizes reserved name checking and ensures DNS servers are not contacted for these special cases.

Key Changes:

  • Refactored localhost resolution logic into a shared CheckIsReservedDnsName method that handles both "localhost" and "invalid" domains plus their subdomains
  • Added comprehensive test coverage for reserved name resolution including subdomain variants and explicit root labels

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Libraries/Microsoft.Extensions.ServiceDiscovery.Dns/Resolver/DnsResolver.cs Refactored hardcoded localhost checks into centralized RFC 6761 reserved name handling with support for subdomains and the "invalid" domain
test/Libraries/Microsoft.Extensions.ServiceDiscovery.Dns.Tests/Resolver/ResolveAddressesTests.cs Added test cases for subdomain variants of reserved names and renamed test to reflect broader scope

@rzikm
Copy link
Copy Markdown
Member Author

rzikm commented Dec 1, 2025

@ReubenBond gentle ping here, can we get this reviewed?

@stephentoub
Copy link
Copy Markdown
Member

@ReubenBond looks like this is waiting on you?

@rzikm
Copy link
Copy Markdown
Member Author

rzikm commented Feb 9, 2026

@ReubenBond gentle ping here

@ReubenBond
Copy link
Copy Markdown
Member

Apologies for the long delay, @rzikm

@rzikm rzikm enabled auto-merge (squash) March 10, 2026 09:22
@rzikm rzikm merged commit 1d0edfc into main Mar 10, 2026
6 checks passed
@rzikm rzikm deleted the reserved-domain-names branch March 10, 2026 10:37
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants