ip地址优化

This commit is contained in:
wxl 2025-01-21 21:48:57 +08:00
parent e1cfe605ea
commit 482f78aee2
5 changed files with 15 additions and 5 deletions

View File

@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
public class AddressUtils {
private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
// 未知地址
public static final String UNKNOWN = "未知地址";
@ -24,10 +25,11 @@ public class AddressUtils {
String rspStr = RegionUtil.getRegion(ip);
if (StringUtils.isNotEmpty(rspStr)) {
String[] obj = rspStr.split("\\|");
// String region = obj[2];
String region = obj[2];
String city = obj[3];
// return String.format("%s%s", region, city);
if("0".equals(city)){
return String.format("%s", region);
}
return String.format("%s", city);
}
} catch (Exception e) {
@ -73,7 +75,8 @@ public class AddressUtils {
public static void main(String[] args) {
String realAddress = getRealAddress("117.136.79.113");
String realAddress = getRealAddress("103.85.74.92");
;
System.out.println("realAddress = " + realAddress);
}
}

View File

@ -2,6 +2,7 @@ package com.dd.admin.common.utils;
import com.alibaba.fastjson.JSONObject;
import com.sun.javaws.Main;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -17,6 +18,8 @@ import java.util.Map;
*/
public class PureNetUtils {
private static final Logger log = LoggerFactory.getLogger(PureNetUtils.class);
/**

View File

@ -28,6 +28,10 @@ public class RegionUtil {
static DbConfig config = null;
static DbSearcher searcher = null;
public static void main(String[] args) {
getRegion("103.85.74.92");
}
// 初始化IP库
static {
try {

BIN
web/dist.rar Normal file

Binary file not shown.