From 3aa830fc78c66ff7e2821710b4a07619503cea82 Mon Sep 17 00:00:00 2001 From: Gary Date: Thu, 21 Mar 2024 06:51:19 +0800 Subject: [PATCH] =?UTF-8?q?1.update=20unknow=20ip=20from=200=20to=20'?= =?UTF-8?q?=E6=9C=AA=E7=9F=A5ip'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luoo_comment/src/main/java/com/luoo/comment/util/IpUtil.java | 3 ++- luoo_user/src/main/java/com/luoo/user/util/IpUtil.java | 3 ++- luoo_user/src/test/java/com/luoo/user/util/IpUtilTest.java | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/luoo_comment/src/main/java/com/luoo/comment/util/IpUtil.java b/luoo_comment/src/main/java/com/luoo/comment/util/IpUtil.java index d0c1175..14195a2 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/util/IpUtil.java +++ b/luoo_comment/src/main/java/com/luoo/comment/util/IpUtil.java @@ -28,7 +28,8 @@ public class IpUtil { try { String ipLocation = searcher.search(ip); if (ipLocation.startsWith(Constants.IP_LOCATION_CHINA)) { - return ipLocation.split("\\|")[2].replaceFirst("省", ""); + String province = ipLocation.split("\\|")[2].replaceFirst("省", ""); + return "0".equals(province)?UNKNOW_IP:province; } if (ipLocation.contains(INTERNAL_IP)) { return INTERNAL_IP; diff --git a/luoo_user/src/main/java/com/luoo/user/util/IpUtil.java b/luoo_user/src/main/java/com/luoo/user/util/IpUtil.java index 5a60036..a87fec0 100644 --- a/luoo_user/src/main/java/com/luoo/user/util/IpUtil.java +++ b/luoo_user/src/main/java/com/luoo/user/util/IpUtil.java @@ -27,7 +27,8 @@ public class IpUtil { try { String ipLocation = searcher.search(ip); if (ipLocation.startsWith(Constants.IP_LOCATION_CHINA)) { - return ipLocation.split("\\|")[2].replaceFirst("省", ""); + String province = ipLocation.split("\\|")[2].replaceFirst("省", ""); + return "0".equals(province)?UNKNOW_IP:province; } if (ipLocation.contains(INTERNAL_IP)) { return INTERNAL_IP; diff --git a/luoo_user/src/test/java/com/luoo/user/util/IpUtilTest.java b/luoo_user/src/test/java/com/luoo/user/util/IpUtilTest.java index fa9ddb9..a8f96d2 100644 --- a/luoo_user/src/test/java/com/luoo/user/util/IpUtilTest.java +++ b/luoo_user/src/test/java/com/luoo/user/util/IpUtilTest.java @@ -16,6 +16,9 @@ public class IpUtilTest { String ip3="192.168.3.0"; System.out.println(IpUtil.getIpLocation(ip3)); + + String ip4="39.144.187.227"; + System.out.println(IpUtil.getIpLocation(ip4)); } }