Skip to content

Conversation

@rzikm
Copy link
Member

@rzikm rzikm commented Oct 15, 2025

Replaces dotnet/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
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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants