Repository navigation
[ISSUE #11483] fix(remoting): skip CIDR matching for non-IPv4 hosts when choosing a SOCKS proxy - #11484
Open
weidong-qi wants to merge 1 commit into
Open
[ISSUE #11483] fix(remoting): skip CIDR matching for non-IPv4 hosts when choosing a SOCKS proxy#11484weidong-qi wants to merge 1 commit into
weidong-qi wants to merge 1 commit into
Conversation
…osts when choosing a SOCKS proxy NettyRemotingClient#getProxy passed the host part of every address to RemotingHelper#ipInCIDR, which only parses dotted IPv4 literals. With any CIDR other than 0.0.0.0/0 configured in socksProxyConfig, connecting to a hostname such as namesrv.example.com:9876 (or an IPv6 address) threw a NumberFormatException and the connection attempt failed. Only run the CIDR check for IPv4 hosts; other hosts can still match the 0.0.0.0/0 catch-all entry.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #11484 +/- ##
=============================================
- Coverage 49.79% 49.76% -0.03%
+ Complexity 14387 14373 -14
=============================================
Files 1390 1390
Lines 103264 103265 +1
Branches 13504 13504
=============================================
- Hits 51419 51390 -29
- Misses 45657 45673 +16
- Partials 6188 6202 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Which Issue(s) This PR Fixes
Brief Description
NettyRemotingClient#getProxycalledRemotingHelper#ipInCIDRfor every configured CIDR except the literal0.0.0.0/0.ipInCIDRonly parses dotted IPv4 literals, so a target given as a hostname (e.g.namesrv.example.com:9876) or an IPv6 literal threwNumberFormatException, and the connection attempt failed.This change runs the CIDR check only when the host is a valid IPv4 literal (
IPAddressUtils#isValidIPv4). Other hosts skip the specific CIDR entries and can still match the0.0.0.0/0catch-all entry.ipInCIDRitself is untouched, so this does not overlap with #11068.How Did You Test This Change?
Added three cases to
NettyRemotingClientTest:testGetProxyMatchesIpv4AddressInCidr: IPv4 inside / outside10.0.0.0/8keeps its current behavior.testGetProxySkipsCidrForNonIpv4Host:namesrv.example.com:9876and[fe80::1]:9876return no proxy instead of throwing.testGetProxyDefaultCidrMatchesHostname: a hostname still matches the0.0.0.0/0entry.Before the fix,
testGetProxySkipsCidrForNonIpv4Hostfails withNumberFormatException: For input string: "namesrv". After the fix all 19 tests inNettyRemotingClientTestpass, andmvn -pl remoting validatereports 0 Checkstyle violations.