From a063840a0e943d6d43d03c37129a9c40e612a2c1 Mon Sep 17 00:00:00 2001 From: PureGero Date: Thu, 2 Jun 2022 07:58:22 +1000 Subject: [PATCH] Check HAProxyMessage type is PROXY (#7864) --- patches/server/Add-support-for-Proxy-Protocol.patch | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/patches/server/Add-support-for-Proxy-Protocol.patch b/patches/server/Add-support-for-Proxy-Protocol.patch index 8bfa258641..0a95a7c771 100644 --- a/patches/server/Add-support-for-Proxy-Protocol.patch +++ b/patches/server/Add-support-for-Proxy-Protocol.patch @@ -46,13 +46,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + if (msg instanceof io.netty.handler.codec.haproxy.HAProxyMessage message) { -+ String realaddress = message.sourceAddress(); -+ int realport = message.sourcePort(); ++ if (message.command() == io.netty.handler.codec.haproxy.HAProxyCommand.PROXY) { ++ String realaddress = message.sourceAddress(); ++ int realport = message.sourcePort(); + -+ SocketAddress socketaddr = new java.net.InetSocketAddress(realaddress, realport); ++ SocketAddress socketaddr = new java.net.InetSocketAddress(realaddress, realport); + -+ Connection connection = (Connection) channel.pipeline().get("packet_handler"); -+ connection.address = socketaddr; ++ Connection connection = (Connection) channel.pipeline().get("packet_handler"); ++ connection.address = socketaddr; ++ } + } else { + super.channelRead(ctx, msg); + }