This is an automated email from the ASF dual-hosted git repository.
mmarshall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 7dc9a5f1b26 [cleanup][proxy] Use correct address for HAProxyMessage
destination (#16045)
7dc9a5f1b26 is described below
commit 7dc9a5f1b269b05e7d7c1b101a89637951c55026
Author: Michael Marshall <[email protected]>
AuthorDate: Fri Oct 14 08:05:11 2022 -0700
[cleanup][proxy] Use correct address for HAProxyMessage destination (#16045)
* [fix][proxy] Use correct channel for HAProxyMessage dest address
* Fix implementation after researching HAProxy
### Motivation
When reading through the Proxy code, I noticed that the `remoteAddress` was
used where it probably makes sense to use the `localAddress`.
After researching it a bit with the AWS docs
https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-proxy-protocol.html
and the protocol spec
http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt, I think this
implementation is correct.
We could look at using the value in the broker logs if we wanted to make it
clear which proxy the traffic is ingressing through. For now, I propose we just
fix the code in the proxy.
### Modifications
* Replace `inboundChannel.localAddress` with `inboundChannel.localAddress`.
* Fix type checking
- [x] `doc-not-needed`
---
.../main/java/org/apache/pulsar/proxy/server/DirectProxyHandler.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git
a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/DirectProxyHandler.java
b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/DirectProxyHandler.java
index 1179b4db880..3994cf9034a 100644
---
a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/DirectProxyHandler.java
+++
b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/DirectProxyHandler.java
@@ -243,11 +243,11 @@ public class DirectProxyHandler {
.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
} else {
if (inboundChannel.remoteAddress() instanceof InetSocketAddress
- && outboundChannel.localAddress() instanceof
InetSocketAddress) {
+ && inboundChannel.localAddress() instanceof
InetSocketAddress) {
InetSocketAddress clientAddress = (InetSocketAddress)
inboundChannel.remoteAddress();
String sourceAddress =
clientAddress.getAddress().getHostAddress();
int sourcePort = clientAddress.getPort();
- InetSocketAddress proxyAddress = (InetSocketAddress)
inboundChannel.remoteAddress();
+ InetSocketAddress proxyAddress = (InetSocketAddress)
inboundChannel.localAddress();
String destinationAddress =
proxyAddress.getAddress().getHostAddress();
int destinationPort = proxyAddress.getPort();
HAProxyMessage msg = new
HAProxyMessage(HAProxyProtocolVersion.V1, HAProxyCommand.PROXY,