Repository navigation
fix(core): support hostnames whose last label starts with a digit - #13144
Open
siddiqueirshad wants to merge 1 commit into
Open
siddiqueirshad wants to merge 1 commit into
siddiqueirshad wants to merge 1 commit into
Conversation
In DnsNameResolver and GrpcUtil.authorityFromHostAndPort, hostnames were validated and parsed via java.net.URI. Because java.net.URI implements RFC 2396 grammar where the toplabel of a hostname must begin with an alphabetic character (JDK-8188305), valid RFC 1123 hostnames whose last label starts with a digit (e.g. Kubernetes services in namespaces like otlp.1234-k8s-namespace) resulted in URI.getHost() returning null and URI constructors throwing URISyntaxException. This change: 1. In DnsNameResolver, if nameUri.getHost() is null due to RFC 2396 restrictions, extracts host and port from nameUri.getAuthority(). 2. In GrpcUtil.authorityFromHostAndPort, falls back to manual host/port concatenation validated through checkAuthority() when new URI(...) throws URISyntaxException. 3. Adds unit tests in DnsNameResolverProviderTest and GrpcUtilTest. Fixes grpc#13075 Signed-off-by: siddiqui irshad <mohdirshad1306@gmail.com>
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
Fixes #13075.
In
DnsNameResolverandGrpcUtil.authorityFromHostAndPort, hostnames were previously validated and parsed exclusively viajava.net.URI.Because
java.net.URIfollows RFC 2396 grammar, where the top-level label of a hostname is constrained to begin with an alphabetic character (alpha), valid RFC 1123 hostnames whose last label starts with a digit (such as Kubernetes service endpoints likeotlp.1234-k8s-namespace) result in:nameUri.getHost()returningnullinDnsNameResolver, causingIllegalArgumentException: Invalid DNS name.new URI(null, null, host, port, null, null, null)throwingURISyntaxExceptioninGrpcUtil.authorityFromHostAndPort, causingIllegalArgumentException: Invalid host or port.Fix
DnsNameResolver: WhennameUri.getHost()isnull, fall back to parsinghostandportfromnameUri.getAuthority().GrpcUtil.authorityFromHostAndPort: Whennew URI(null, null, host, port, null, null, null)throwsURISyntaxException, combine host (IPv6-bracketed if necessary) and port into an authority string and validate it throughcheckAuthority().DnsNameResolverProviderTestandGrpcUtilTest.Fixes #13075