/* */ package com.archive.common.utils; /* */ /* */ import com.alibaba.fastjson.JSONObject; /* */ import com.archive.common.utils.IpUtils; /* */ import com.archive.common.utils.StringUtils; /* */ import com.archive.common.utils.http.HttpUtils; /* */ import com.archive.framework.config.ArchiveConfig; /* */ import org.slf4j.Logger; /* */ import org.slf4j.LoggerFactory; /* */ /* */ /* */ /* */ /* */ /* */ public class AddressUtils /* */ { /* 17 */ private static final Logger log = LoggerFactory.getLogger(com.archive.common.utils.AddressUtils.class); /* */ /* */ /* */ public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp"; /* */ /* */ /* */ public static final String UNKNOWN = "XX XX"; /* */ /* */ /* */ public static String getRealAddressByIP(String ip) { /* 27 */ String address = "XX XX"; /* */ /* 29 */ if (IpUtils.internalIp(ip)) /* */ { /* 31 */ return "内网IP"; /* */ } /* 33 */ if (ArchiveConfig.isAddressEnabled()) { /* */ /* */ try { /* */ /* 37 */ String rspStr = HttpUtils.sendGet("http://whois.pconline.com.cn/ipJson.jsp", "ip=" + ip + "&json=true", "GBK"); /* 38 */ if (StringUtils.isEmpty(rspStr)) { /* */ /* 40 */ log.error("获取地理位置异常 {}", ip); /* 41 */ return "XX XX"; /* */ } /* 43 */ JSONObject obj = JSONObject.parseObject(rspStr); /* 44 */ String region = obj.getString("pro"); /* 45 */ String city = obj.getString("city"); /* 46 */ return String.format("%s %s", new Object[] { region, city }); /* */ } /* 48 */ catch (Exception e) { /* */ /* 50 */ log.error("获取地理位置异常 {}", e); /* */ } /* */ } /* 53 */ return address; /* */ } /* */ } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\AddressUtils.class * Java compiler version: 8 (52.0) * JD-Core Version: 1.1.3 */