From c678f70836dda351ec1a4e9c6bd18898b97faad3 Mon Sep 17 00:00:00 2001
From: TanYibin <5491541@qq.com>
Date: Sun, 18 Feb 2024 11:45:43 +0800
Subject: [PATCH] 优化启动IP信息获取逻辑

---
 huaheng-wms-core/src/main/java/org/jeecg/JeecgSystemApplication.java | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/huaheng-wms-core/src/main/java/org/jeecg/JeecgSystemApplication.java b/huaheng-wms-core/src/main/java/org/jeecg/JeecgSystemApplication.java
index 5f595ed..9a84f4e 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/JeecgSystemApplication.java
+++ b/huaheng-wms-core/src/main/java/org/jeecg/JeecgSystemApplication.java
@@ -57,8 +57,6 @@ public class JeecgSystemApplication extends SpringBootServletInitializer {
 
     public static InetAddress getLocalHostExactAddress() {
         try {
-            InetAddress inetAddress = null;
-
             Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
             while (networkInterfaces.hasMoreElements()) {
                 NetworkInterface netInterface = networkInterfaces.nextElement();
@@ -67,12 +65,12 @@ public class JeecgSystemApplication extends SpringBootServletInitializer {
                 while (addresses.hasMoreElements()) {
                     InetAddress ipTmp = addresses.nextElement();
                     if (ipTmp != null && ipTmp instanceof Inet4Address && ipTmp.isSiteLocalAddress() && !ipTmp.isLoopbackAddress()
-                        && ipTmp.getHostAddress().indexOf(":") == -1) {
-                        inetAddress = ipTmp;
+                        && ipTmp.getHostAddress().indexOf(":") == -1 && !ipTmp.getHostAddress().endsWith(".1")) {
+                        return ipTmp;
                     }
                 }
             }
-            return inetAddress == null ? InetAddress.getLocalHost() : inetAddress;
+            return InetAddress.getLocalHost();
         } catch (SocketException | UnknownHostException e) {
             e.printStackTrace();
         }
--
libgit2 0.22.2