You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2019/11/04 08:03:38 UTC

[GitHub] [rocketmq] vongosling commented on a change in pull request #1563: [ISSUE #1564]Fix the ip filter logic in ipv6/ipv4 coexist environment

vongosling commented on a change in pull request #1563: [ISSUE #1564]Fix the ip filter logic in ipv6/ipv4 coexist environment
URL: https://github.com/apache/rocketmq/pull/1563#discussion_r341930045
 
 

 ##########
 File path: common/src/main/java/org/apache/rocketmq/common/UtilAll.java
 ##########
 @@ -440,13 +440,11 @@ public static boolean isInternalIP(byte[] ip) {
         return false;
     }
 
-    public static boolean isInternalV6IP(byte[] ip) {
-        if (ip.length != 16) {
-            throw new RuntimeException("illegal ipv6 bytes");
-        }
-
-        //FEC0:0000:0000:0000:0000:0000:0000:0000/10
-        if (ip[0] == (byte) 254 && ip[1] >= (byte) 192) {
+    public static boolean isInternalV6IP(InetAddress inetAddr) {
+        if (inetAddr.isAnyLocalAddress() // Wild card ipv6
+            || inetAddr.isLinkLocalAddress() // Single broadcast ipv6 address: fe80:xx:xx...
+            || inetAddr.isLoopbackAddress() //Loopback ipv6 address
+            || inetAddr.isSiteLocalAddress()) { // Site local ipv6 address: fec0:xx:xx...
 
 Review comment:
   Good catch

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services