[ https://issues.apache.org/jira/browse/ARTEMIS-3915?focusedWorklogId=982652&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-982652 ]
ASF GitHub Bot logged work on ARTEMIS-3915: ------------------------------------------- Author: ASF GitHub Bot Created on: 10/Sep/25 15:29 Start Date: 10/Sep/25 15:29 Worklog Time Spent: 10m Work Description: gemmellr commented on code in PR #5908: URL: https://github.com/apache/activemq-artemis/pull/5908#discussion_r2337148033 ########## artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyServerConnection.java: ########## @@ -51,4 +58,55 @@ public void setSNIHostname(String sniHostname) { public String getRouter() { return router; } + + /** + * {@return a string representation of the remote address of this connection; if this connection was made via the + * proxy protocol then this will be the original address, not the proxy address} + */ + @Override + public String getRemoteAddress() { + String proxyProtocolSourceAddress = channel.attr(PROXY_PROTOCOL_SOURCE_ADDRESS).get(); + String proxyProtocolSourcePort = channel.attr(PROXY_PROTOCOL_SOURCE_PORT).get(); + if (proxyProtocolSourceAddress != null && !proxyProtocolSourceAddress.isEmpty() && proxyProtocolSourcePort != null && !proxyProtocolSourcePort.isEmpty()) { + return proxyProtocolSourceAddress + ":" + proxyProtocolSourcePort; + } else { + return super.getRemoteAddress(); + } + } + + /** + * {@return if this connection is made via the proxy protocol then this will be the address of the proxy} + */ + public String getProxyAddress() { + String proxyProtocolDestinationAddress = channel.attr(PROXY_PROTOCOL_DESTINATION_ADDRESS).get(); + String proxyProtocolDestinationPort = channel.attr(PROXY_PROTOCOL_DESTINATION_PORT).get(); + if (proxyProtocolDestinationAddress != null && !proxyProtocolDestinationAddress.isEmpty() && proxyProtocolDestinationPort != null && !proxyProtocolDestinationPort.isEmpty()) { + return proxyProtocolDestinationAddress + ":" + proxyProtocolDestinationPort; + } else { + return null; + } + } + + /** + * {@return the version of the proxy protocol used to make the connection or null if not applicable} + */ + public String getProxyVersion() { + return channel.attr(PROXY_PROTOCOL_VERSION).get() == null ? null : channel.attr(PROXY_PROTOCOL_VERSION).get().toString(); + } + + public static String getProxyAddress(Connection connection) { + if (connection instanceof NettyServerConnection nettyServerConnection) { Review Comment: Seems like you removed the instanceof by switching it passing SocketAddress, and now use the static method much more widely, so yep the rest is kinda tangential now. Issue Time Tracking ------------------- Worklog Id: (was: 982652) Time Spent: 6h 10m (was: 6h) > Support PROXY Protocol > ---------------------- > > Key: ARTEMIS-3915 > URL: https://issues.apache.org/jira/browse/ARTEMIS-3915 > Project: ActiveMQ Artemis > Issue Type: Improvement > Components: Broker > Reporter: João Santos > Assignee: Justin Bertram > Priority: Major > Labels: pull-request-available > Time Spent: 6h 10m > Remaining Estimate: 0h > > [HAProxy|http://www.haproxy.org/] is a widely known and used TCP Load > Balancer and especially useful for an ActiveMQ Artemis clustered environment. > Although possible to functionally implement with both products current > features, Artemis does not support the PROXY protocol, which prevents it's > broker nodes from inferring the real remote client IP address when behind an > HAProxy instance. > Since Netty sockets implementation already seems to support this protocol > (discussed w/ [~jbertram] on DEV mailing list), it shouldn't be a big leap to > adding support for the protocol on Artemis acceptors, thus improving the > deployment of the use case at hand. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@activemq.apache.org For additional commands, e-mail: issues-h...@activemq.apache.org For further information, visit: https://activemq.apache.org/contact