You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2023/07/10 06:13:24 UTC
[rocketmq] branch develop updated: [ISSUE #7008] Fix the issue of protocol parsing failure when using haproxy and tls together (#7009)
This is an automated email from the ASF dual-hosted git repository.
lizhimin pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push:
new 58550f074e [ISSUE #7008] Fix the issue of protocol parsing failure when using haproxy and tls together (#7009)
58550f074e is described below
commit 58550f074ec101c0a158ede0df1839950e08837a
Author: rongtong <ji...@163.com>
AuthorDate: Mon Jul 10 14:13:18 2023 +0800
[ISSUE #7008] Fix the issue of protocol parsing failure when using haproxy and tls together (#7009)
---
.../rocketmq/remoting/netty/NettyRemotingServer.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
index 94ffd8d07a..445f06cc63 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
@@ -459,13 +459,13 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
}
@Override
- protected void channelRead0(ChannelHandlerContext ctx, ByteBuf in) {
+ protected void channelRead0(ChannelHandlerContext ctx, ByteBuf byteBuf) {
try {
- ProtocolDetectionResult<HAProxyProtocolVersion> ha = HAProxyMessageDecoder.detectProtocol(in);
- if (ha.state() == ProtocolDetectionState.NEEDS_MORE_DATA) {
+ ProtocolDetectionResult<HAProxyProtocolVersion> detectionResult = HAProxyMessageDecoder.detectProtocol(byteBuf);
+ if (detectionResult.state() == ProtocolDetectionState.NEEDS_MORE_DATA) {
return;
}
- if (ha.state() == ProtocolDetectionState.DETECTED) {
+ if (detectionResult.state() == ProtocolDetectionState.DETECTED) {
ctx.pipeline().addAfter(defaultEventExecutorGroup, ctx.name(), HA_PROXY_DECODER, new HAProxyMessageDecoder())
.addAfter(defaultEventExecutorGroup, HA_PROXY_DECODER, HA_PROXY_HANDLER, new HAProxyMessageHandler())
.addAfter(defaultEventExecutorGroup, HA_PROXY_HANDLER, TLS_MODE_HANDLER, tlsModeHandler);
@@ -481,7 +481,7 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
}
// Hand over this message to the next .
- ctx.fireChannelRead(in.retain());
+ ctx.fireChannelRead(byteBuf.retain());
} catch (Exception e) {
log.error("process proxy protocol negotiator failed.", e);
throw e;
@@ -503,8 +503,8 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
@Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) {
- // Peek the first byte to determine if the content is starting with TLS handshake
- byte b = msg.getByte(0);
+ // Peek the current read index byte to determine if the content is starting with TLS handshake
+ byte b = msg.getByte(msg.readerIndex());
if (b == HANDSHAKE_MAGIC_CODE) {
switch (tlsMode) {