This is an automated email from the ASF dual-hosted git repository.

hzh0425 pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new e0ed87dc9 [ISSUE #5740] Fix util.getIP sometimes choose localhost over 
LAN ip. (#5856)
e0ed87dc9 is described below

commit e0ed87dc9c261b74225de5b67acee141d36ff593
Author: RagingSpud <[email protected]>
AuthorDate: Sat Jan 14 21:43:04 2023 +0800

    [ISSUE #5740] Fix util.getIP sometimes choose localhost over LAN ip. (#5856)
---
 common/src/main/java/org/apache/rocketmq/common/UtilAll.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java 
b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
index ce2f6a5e6..3c32e7c81 100644
--- a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
+++ b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
@@ -517,8 +517,10 @@ public class UtilAll {
         //10.0.0.0~10.255.255.255
         //172.16.0.0~172.31.255.255
         //192.168.0.0~192.168.255.255
+        //127.0.0.0~127.255.255.255
         if (ip[0] == (byte) 10) {
-
+            return true;
+        } else if (ip[0] == (byte) 127) {
             return true;
         } else if (ip[0] == (byte) 172) {
             if (ip[1] >= (byte) 16 && ip[1] <= (byte) 31) {
@@ -604,7 +606,7 @@ public class UtilAll {
                             if (ipCheck(ipByte)) {
                                 if (!isInternalIP(ipByte)) {
                                     return ipByte;
-                                } else if (internalIP == null) {
+                                } else if (internalIP == null || internalIP[0] 
== (byte) 127) {
                                     internalIP = ipByte;
                                 }
                             }

Reply via email to