gosonzhang commented on a change in pull request #97:
URL: https://github.com/apache/incubator-tubemq/pull/97#discussion_r431196936



##########
File path: 
tubemq-core/src/main/java/org/apache/tubemq/corebase/utils/AddressUtils.java
##########
@@ -130,4 +137,50 @@ public static String getRemoteAddressIP(Channel channel) {
         }
         return strRemoteIP;
     }
+
+    public static Enumeration<NetworkInterface> listNetworkInterface() {
+        try {
+            return NetworkInterface.getNetworkInterfaces();
+        } catch (SocketException e) {
+            throw new AddressException(e);
+        }
+    }
+
+    public static String getIPV4LocalAddress() {
+        try {
+            return doGetIPV4LocalAddress();
+        } catch (SocketException | UnknownHostException e) {
+            String errorMsg = "Unable to obtain local IP, please check if the 
local network is normal";
+            throw new AddressException(errorMsg, e);
+        }
+    }
+
+    private static String doGetIPV4LocalAddress() throws SocketException, 
UnknownHostException {
+        Enumeration<NetworkInterface> enumeration = 
NetworkInterface.getNetworkInterfaces();
+
+        while (enumeration.hasMoreElements()) {
+            NetworkInterface networkInterface = enumeration.nextElement();
+            if ("docker0".equals(networkInterface.getName()) || 
!networkInterface.isUp()) {

Review comment:
       Need to add NetworkInterface isLoopback() status judgment




----------------------------------------------------------------
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:
[email protected]


Reply via email to