jbertram commented on code in PR #5908:
URL: https://github.com/apache/activemq-artemis/pull/5908#discussion_r2334185172


##########
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:
   I'm ambivalent on this. Maybe this could be a subsequent PR?



-- 
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.

To unsubscribe, e-mail: [email protected]

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to