kezhuw commented on code in PR #2280: URL: https://github.com/apache/zookeeper/pull/2280#discussion_r2227380100
########## zookeeper-server/src/main/java/org/apache/zookeeper/server/auth/IPAuthenticationProvider.java: ########## @@ -93,9 +230,11 @@ private void mask(byte[] b, int bits) { } public boolean matches(String id, String aclExpr) { + LOG.info("id: '{}' aclExpr: {}", id, aclExpr); Review Comment: `LOG.trace` or delete it ? ########## zookeeper-server/src/main/java/org/apache/zookeeper/server/auth/IPAuthenticationProvider.java: ########## @@ -55,16 +62,20 @@ public List<Id> handleAuthentication(HttpServletRequest request, byte[] authData // This is a bit weird but we need to return the address and the number of // bytes (to distinguish between IPv4 and IPv6 private byte[] addr2Bytes(String addr) { - byte[] b = v4addr2Bytes(addr); - // TODO Write the v6addr2Bytes - return b; + if (addr.contains(":")) { + LOG.info("Attempting to parse as IPv6..."); + return v6addr2Bytes(addr); + } else if (addr.contains(".")) { + LOG.info("Attempting to parse as IPv4..."); + return v4addr2Bytes(addr); + } else { + LOG.info("Input string does not resemble an IPv4 or IPv6 address: {}", addr); + return null; + } } private byte[] v4addr2Bytes(String addr) { String[] parts = addr.split("\\.", -1); - if (parts.length != 4) { Review Comment: Why this got dropped ? ########## zookeeper-server/src/main/java/org/apache/zookeeper/server/auth/IPAuthenticationProvider.java: ########## @@ -93,9 +230,11 @@ private void mask(byte[] b, int bits) { } public boolean matches(String id, String aclExpr) { + LOG.info("id: '{}' aclExpr: {}", id, aclExpr); String[] parts = aclExpr.split("/", 2); byte[] aclAddr = addr2Bytes(parts[0]); if (aclAddr == null) { + LOG.info("ACL Expr is null"); Review Comment: I think the log above is enough to figure out `false` case without being verbose. -- 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