li4wang commented on code in PR #1943: URL: https://github.com/apache/zookeeper/pull/1943#discussion_r1040657179
########## zookeeper-server/src/main/java/org/apache/zookeeper/server/auth/IPAuthenticationProvider.java: ########## @@ -128,4 +131,18 @@ public boolean isValid(String id) { return true; } + /** + * Returns the HTTP(s) client IP address + * @param request HttpServletRequest + * @return IP address + */ + public static String getClientIPAddress(final HttpServletRequest request) { + // to handle the case that a HTTP(s) client connects via a proxy or load balancer + final String xForwardedForHeader = request.getHeader(X_FORWARDED_FOR_HEADER_NAME); + if (xForwardedForHeader == null) { + return request.getRemoteAddr(); + } + // the format of the field is: X-Forwarded-For: client, proxy1, proxy2 ... + return new StringTokenizer(xForwardedForHeader, ",").nextToken().trim(); + } Review Comment: Yep -- 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: notifications-unsubscr...@zookeeper.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org