codelipenghui commented on a change in pull request #8686:
URL: https://github.com/apache/pulsar/pull/8686#discussion_r530310262



##########
File path: 
pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/DirectProxyHandler.java
##########
@@ -143,10 +150,56 @@ protected void initChannel(SocketChannel ch) throws 
Exception {
                 inboundOutboundChannelMap.put(outboundChannel.id() , 
inboundChannel.id());
             }
 
-
+            if (config.isHaProxyProtocolEnabled()) {
+                if (proxyConnection.hasHAProxyMessage()) {
+                    
outboundChannel.writeAndFlush(encodeProxyProtocolMessage(proxyConnection.getHAProxyMessage()));
+                } else {
+                    if (inboundChannel.remoteAddress() instanceof 
InetSocketAddress) {
+                        InetSocketAddress clientAddress = (InetSocketAddress) 
inboundChannel.remoteAddress();
+                        String sourceAddress = 
clientAddress.getAddress().getHostAddress();
+                        int sourcePort = clientAddress.getPort();
+                        if (outboundChannel.localAddress() instanceof 
InetSocketAddress) {
+                            InetSocketAddress proxyAddress = 
(InetSocketAddress) inboundChannel.remoteAddress();
+                            String destinationAddress = 
proxyAddress.getAddress().getHostAddress();
+                            int destinationPort = proxyAddress.getPort();
+                            HAProxyMessage msg = new 
HAProxyMessage(HAProxyProtocolVersion.V1, HAProxyCommand.PROXY,

Review comment:
       It's not a required for this PR, we can support the proxy set the 
different protocol version in the following PRs.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to