Skip to content

Conversation

@rzikm
Copy link
Member

@rzikm rzikm commented Jul 10, 2025

Description

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

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copilot AI review requested due to automatic review settings July 10, 2025 11:04
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 reserved DNS names handling in the managed DNS resolver. The implementation extends the existing localhost handling to include subdomains (e.g., service.localhost) and adds support for the "invalid" reserved name, ensuring both resolve without contacting DNS servers as required by the RFC.

Key changes:

  • Refactored hardcoded localhost handling into a generic reserved name system
  • Added support for localhost subdomains and the "invalid" reserved name
  • Enhanced test coverage for special DNS name resolution scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Microsoft.Extensions.ServiceDiscovery.Dns/Resolver/DnsResolver.cs Refactored localhost handling into generic reserved name system with RFC 6761 compliance
tests/Microsoft.Extensions.ServiceDiscovery.Dns.Tests/Resolver/ResolveAddressesTests.cs Added comprehensive test coverage for reserved DNS names including subdomains
Comments suppressed due to low confidence (1)

tests/Microsoft.Extensions.ServiceDiscovery.Dns.Tests/Resolver/ResolveAddressesTests.cs:236

  • The parameter name 'localhost' is misleading since it's used for both localhost and invalid names. Consider renaming to 'name' or 'specialName' to better reflect its purpose.
    public async Task ResolveIP_SpecialName(string localhost, AddressFamily family, string? addressAsString)

@rzikm
Copy link
Member Author

rzikm commented Oct 15, 2025

Replaced by dotnet/extensions#6924

@rzikm rzikm closed this Oct 15, 2025
@dotnet-policy-service dotnet-policy-service bot added this to the 13.0 milestone Oct 15, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2025
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.

1 participant