Skip to content

[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
apache:developfrom
weidong-qi:fix-socks-proxy-hostname
Open

weidong-qi wants to merge 1 commit into
apache:developfrom
weidong-qi:fix-socks-proxy-hostname

Conversation

@weidong-qi

Copy link
Copy Markdown

Which Issue(s) This PR Fixes

Brief Description

NettyRemotingClient#getProxy called RemotingHelper#ipInCIDR for every configured CIDR except the literal 0.0.0.0/0. ipInCIDR only parses dotted IPv4 literals, so a target given as a hostname (e.g. namesrv.example.com:9876) or an IPv6 literal threw NumberFormatException, 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 the 0.0.0.0/0 catch-all entry. ipInCIDR itself is untouched, so this does not overlap with #11068.

How Did You Test This Change?

Added three cases to NettyRemotingClientTest:

  • testGetProxyMatchesIpv4AddressInCidr: IPv4 inside / outside 10.0.0.0/8 keeps its current behavior.
  • testGetProxySkipsCidrForNonIpv4Host: namesrv.example.com:9876 and [fe80::1]:9876 return no proxy instead of throwing.
  • testGetProxyDefaultCidrMatchesHostname: a hostname still matches the 0.0.0.0/0 entry.

Before the fix, testGetProxySkipsCidrForNonIpv4Host fails with NumberFormatException: For input string: "namesrv". After the fix all 19 tests in NettyRemotingClientTest pass, and mvn -pl remoting validate reports 0 Checkstyle violations.

…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-commenter

codecov-commenter commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.76%. Comparing base (57c2dc0) to head (ccbdbba).
⚠️ Report is 8 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] SOCKS proxy CIDR matching throws NumberFormatException for hostname or IPv6 addresses, so the client cannot connect

2 participants