-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cleanup][proxy] Use correct address for HAProxyMessage destination #16045
[cleanup][proxy] Use correct address for HAProxyMessage destination #16045
Conversation
@michaeljmarshall Please provide a correct documentation label for your PR. |
@michaeljmarshall Please provide a correct documentation label for your PR. |
@michaeljmarshall Please provide a correct documentation label for your PR. |
1 similar comment
@michaeljmarshall Please provide a correct documentation label for your PR. |
@@ -233,7 +233,7 @@ private void writeHAProxyMessage() { | |||
InetSocketAddress clientAddress = (InetSocketAddress) inboundChannel.remoteAddress(); | |||
String sourceAddress = clientAddress.getAddress().getHostAddress(); | |||
int sourcePort = clientAddress.getPort(); | |||
InetSocketAddress proxyAddress = (InetSocketAddress) inboundChannel.remoteAddress(); | |||
InetSocketAddress proxyAddress = (InetSocketAddress) outboundChannel.localAddress(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it should be using outboundChannel.remoteAddress()
instead of .localAddress()
.
InetSocketAddress proxyAddress = (InetSocketAddress) outboundChannel.localAddress(); | |
InetSocketAddress proxyAddress = (InetSocketAddress) outboundChannel.remoteAddress(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also change the instanceof
check in the conditional just above this code? I don't know anything about this code other than the fact that the names imply that the inboundChannel.remoteAddress
should not be called twice and assigned to different variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be the address that the client requested. Actually, the destinationAddress
is useless for now since we introduced HAProxyMessage only for getting the real client address even if users use other L4 proxies or the Pulsar proxy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codelipenghui - do you have any insight on this issue? It looks like you contributed some of the original code here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your response @codelipenghui. I finally got back to this and did some research with @lhotari. Based on these docs, https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-proxy-protocol.html, it looks like we want the proxy address. I'm updating the PR now. I think it could be useful to expose the address in the broker logs to make it clear which proxy is doing the routing.
The pr had no activity for 30 days, mark with Stale label. |
eb546e1
to
1316cf4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov Report
@@ Coverage Diff @@
## master #16045 +/- ##
=============================================
+ Coverage 34.91% 46.81% +11.89%
- Complexity 5707 17881 +12174
=============================================
Files 607 1573 +966
Lines 53396 128213 +74817
Branches 5712 14100 +8388
=============================================
+ Hits 18644 60018 +41374
- Misses 32119 62050 +29931
- Partials 2633 6145 +3512
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I am going to classify this as "cleanup" instead of "fix" because it's not really a bug. 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. |
1316cf4
to
34db600
Compare
Motivation
When reading through the Proxy code, I noticed that the
remoteAddress
was used where it probably makes sense to use thelocalAddress
.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.
Modifications
inboundChannel.localAddress
withinboundChannel.localAddress
.doc-not-needed