- Notifications
You must be signed in to change notification settings - Fork845
Implement RFC6761 reserved DNS names handling#6924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
There was a problem hiding this 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
CheckIsReservedDnsNamemethod 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 |
.../Libraries/Microsoft.Extensions.ServiceDiscovery.Dns.Tests/Resolver/ResolveAddressesTests.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
…/Resolver/ResolveAddressesTests.cs
Uh oh!
There was an error while loading.Please reload this page.
Replacesdotnet/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".