[Bug] SOCKS proxy CIDR matching throws NumberFormatException for hostname or IPv6 addresses, so the client cannot connect
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start in NettyRemotingClient#getProxy, then trace how RemotingHelper#ipInCIDR parses hosts against configured CIDR keys. Check the existing tests for SOCKS proxy selection and add coverage for hostname and IPv6 targets with an IPv4 CIDR, plus the 0.0.0.0/0 catch-all. Done means nonmatching targets do not throw and connection setup can proceed; linked pull request #11484 is already open.
索引モデルが issue の本文から書いたものです。
説明
Before Creating the Bug Report
- I found a bug, not just asking a question, which should be created in GitHub Discussions.
- I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.
- I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.
Runtime platform environment
Any (reproduced on macOS)
RocketMQ version
develop, git commit id: 57c2dc04f78cc7e73e6b8c9436ee0fff0d0f46c3
JDK Version
JDK 17
Describe the Bug
NettyRemotingClient#getProxy picks a SOCKS proxy by matching the target host against each CIDR key of socksProxyConfig. For every key other than the literal 0.0.0.0/0 it calls RemotingHelper#ipInCIDR(host, cidr), which parses the host with ipToInt and only accepts dotted IPv4 literals.
When the target address uses a hostname (e.g. namesrv.example.com:9876, common with Kubernetes service names) or an IPv6 literal, ipToInt throws NumberFormatException. The exception escapes getProxy → fetchBootstrap → doConnect, so the client cannot connect to that address at all, even though it should just not match that CIDR.
Steps to Reproduce
NettyClientConfig config = new NettyClientConfig();
config.setSocksProxyConfig("{\"10.0.0.0/8\":{\"addr\":\"127.0.0.1:1080\"}}");
NettyRemotingClient client = new NettyRemotingClient(config);
// any invoke against "namesrv.example.com:9876" reaches getProxy(...)
Calling getProxy("namesrv.example.com:9876") (e.g. via reflection) throws:
java.lang.NumberFormatException: For input string: "namesrv"
at org.apache.rocketmq.remoting.common.RemotingHelper.ipToInt(RemotingHelper.java)
at org.apache.rocketmq.remoting.common.RemotingHelper.ipInCIDR(RemotingHelper.java)
at org.apache.rocketmq.remoting.netty.NettyRemotingClient.getProxy(NettyRemotingClient.java)
What Did You Expect to See?
A hostname or IPv6 host that cannot be compared against an IPv4 CIDR does not match that entry (no proxy, direct connection), and can still match the 0.0.0.0/0 catch-all entry.
What Did You See Instead?
NumberFormatException is thrown and the connection attempt fails.
Additional Context
This is separate from #11068, which fixes the /0 mask computation inside ipInCIDR. The fix proposed here only touches NettyRemotingClient#getProxy, so the two changes do not overlap.
- 主要言語
- Java
- スター
- 22.7k
- フォーク
- 12k
- 平均マージ
- 3日 18時間
- マージ済み PR(30日)
- 17
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/rocketmq のほかの issue
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configuration対応中かも @amalsaidov が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
CompressionType.of fails under the Turkish locale対応中かも @sharanggupta が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
[rocketmq-client-python] TransactionMQProducer allocates an unused producer during initializationオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
[Bug] notifyMasterOnline aborts the long-polling wake-up with a NullPointerException when an arrival drains a bucket first対応中かも @iloveeyjafjalla が 29 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/rocketmq#11441 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Enhancement] FilterFactory duplicate-registration and unregister semantics lack tests対応中かも @chennaji9 が 34 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
apache/rocketmq#11340 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
apache/rocketmq の issue をすべて見る
似ている issue
-
bug emitter:client:csharp
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/typespec#12572 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 1 日以内に返信
-
needs-area-label
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
area/ai area/backend component/zeebe kind/task
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
spAnser/reacharound#38 ·