ip地址优化
This commit is contained in:
parent
e1cfe605ea
commit
482f78aee2
@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
public class AddressUtils {
|
public class AddressUtils {
|
||||||
private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
|
private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
|
||||||
|
|
||||||
|
|
||||||
// 未知地址
|
// 未知地址
|
||||||
public static final String UNKNOWN = "未知地址";
|
public static final String UNKNOWN = "未知地址";
|
||||||
|
|
||||||
@ -24,10 +25,11 @@ public class AddressUtils {
|
|||||||
String rspStr = RegionUtil.getRegion(ip);
|
String rspStr = RegionUtil.getRegion(ip);
|
||||||
if (StringUtils.isNotEmpty(rspStr)) {
|
if (StringUtils.isNotEmpty(rspStr)) {
|
||||||
String[] obj = rspStr.split("\\|");
|
String[] obj = rspStr.split("\\|");
|
||||||
// String region = obj[2];
|
String region = obj[2];
|
||||||
String city = obj[3];
|
String city = obj[3];
|
||||||
|
if("0".equals(city)){
|
||||||
// return String.format("%s%s", region, city);
|
return String.format("%s", region);
|
||||||
|
}
|
||||||
return String.format("%s", city);
|
return String.format("%s", city);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -73,7 +75,8 @@ public class AddressUtils {
|
|||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
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);
|
System.out.println("realAddress = " + realAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.dd.admin.common.utils;
|
|||||||
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.sun.javaws.Main;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -17,6 +18,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class PureNetUtils {
|
public class PureNetUtils {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(PureNetUtils.class);
|
private static final Logger log = LoggerFactory.getLogger(PureNetUtils.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +28,10 @@ public class RegionUtil {
|
|||||||
static DbConfig config = null;
|
static DbConfig config = null;
|
||||||
static DbSearcher searcher = null;
|
static DbSearcher searcher = null;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
getRegion("103.85.74.92");
|
||||||
|
}
|
||||||
|
|
||||||
// 初始化IP库
|
// 初始化IP库
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
|
BIN
web/dist.rar
Normal file
BIN
web/dist.rar
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user