|
|
@ -3,13 +3,11 @@ package org.nl.common.utils; |
|
|
|
import cn.hutool.http.HttpUtil; |
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher; |
|
|
|
import net.dreamlu.mica.ip2region.core.IpInfo; |
|
|
|
import nl.basjes.parse.useragent.UserAgent; |
|
|
|
import nl.basjes.parse.useragent.UserAgentAnalyzer; |
|
|
|
import org.nl.config.other.ElAdminProperties; |
|
|
|
import org.omg.CORBA.UNKNOWN; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
@ -26,7 +24,11 @@ import java.util.Enumeration; |
|
|
|
* @author hengyunabc 2020-10-27 |
|
|
|
* |
|
|
|
*/ |
|
|
|
public class InetAddressUtil { |
|
|
|
public class InetAddUtil { |
|
|
|
|
|
|
|
static { |
|
|
|
System.out.println("InetAddressUtil loading"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于IP定位转换 |
|
|
@ -52,7 +54,7 @@ public class InetAddressUtil { |
|
|
|
|
|
|
|
private static final char SEPARATOR = '_'; |
|
|
|
private static final String UNKNOWN = "unknown"; |
|
|
|
private final static Logger logger = LoggerFactory.getLogger(InetAddressUtil.class); |
|
|
|
private final static Logger logger = LoggerFactory.getLogger(InetAddUtil.class); |
|
|
|
|
|
|
|
/** |
|
|
|
* 获得本机IP。 |
|
|
@ -234,7 +236,7 @@ public class InetAddressUtil { |
|
|
|
* 根据ip获取详细地址 |
|
|
|
*/ |
|
|
|
public static String getHttpCityInfo(String ip) { |
|
|
|
String api = String.format(InetAddressUtil.Url.IP_URL, ip); |
|
|
|
String api = String.format(InetAddUtil.Url.IP_URL, ip); |
|
|
|
JSONObject object = JSONUtil.parseObj(HttpUtil.get(api)); |
|
|
|
return object.get("addr", String.class); |
|
|
|
} |