IpRegion IP地址转换为行政区域
Ip138 ,Ip360 ,Ipchaxun ,Ipcn ,Pconline & Local
This commit is contained in:
@@ -64,6 +64,10 @@ public class HistoryLogin extends JpaBaseEntity implements Serializable{
|
||||
@Column
|
||||
String sourceIp;
|
||||
@Column
|
||||
String ipRegion;
|
||||
@Column
|
||||
String ipLocation;
|
||||
@Column
|
||||
String browser;
|
||||
@Column
|
||||
String platform;
|
||||
@@ -169,6 +173,22 @@ public class HistoryLogin extends JpaBaseEntity implements Serializable{
|
||||
this.sourceIp = sourceIp;
|
||||
}
|
||||
|
||||
public String getIpRegion() {
|
||||
return ipRegion;
|
||||
}
|
||||
|
||||
public void setIpRegion(String ipRegion) {
|
||||
this.ipRegion = ipRegion;
|
||||
}
|
||||
|
||||
public String getIpLocation() {
|
||||
return ipLocation;
|
||||
}
|
||||
|
||||
public void setIpLocation(String ipLocation) {
|
||||
this.ipLocation = ipLocation;
|
||||
}
|
||||
|
||||
public String getBrowser() {
|
||||
return browser;
|
||||
}
|
||||
@@ -258,47 +278,55 @@ public class HistoryLogin extends JpaBaseEntity implements Serializable{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("HistoryLogin [id=");
|
||||
builder.append(id);
|
||||
builder.append(", sessionId=");
|
||||
builder.append(sessionId);
|
||||
builder.append(", userId=");
|
||||
builder.append(userId);
|
||||
builder.append(", username=");
|
||||
builder.append(username);
|
||||
builder.append(", displayName=");
|
||||
builder.append(displayName);
|
||||
builder.append(", loginType=");
|
||||
builder.append(loginType);
|
||||
builder.append(", message=");
|
||||
builder.append(message);
|
||||
builder.append(", code=");
|
||||
builder.append(code);
|
||||
builder.append(", provider=");
|
||||
builder.append(provider);
|
||||
builder.append(", sourceIp=");
|
||||
builder.append(sourceIp);
|
||||
builder.append(", browser=");
|
||||
builder.append(browser);
|
||||
builder.append(", platform=");
|
||||
builder.append(platform);
|
||||
builder.append(", application=");
|
||||
builder.append(application);
|
||||
builder.append(", loginUrl=");
|
||||
builder.append(loginUrl);
|
||||
builder.append(", loginTime=");
|
||||
builder.append(loginTime);
|
||||
builder.append(", logoutTime=");
|
||||
builder.append(logoutTime);
|
||||
builder.append(", startDate=");
|
||||
builder.append(startDate);
|
||||
builder.append(", endDate=");
|
||||
builder.append(endDate);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("HistoryLogin [id=");
|
||||
builder.append(id);
|
||||
builder.append(", sessionId=");
|
||||
builder.append(sessionId);
|
||||
builder.append(", userId=");
|
||||
builder.append(userId);
|
||||
builder.append(", username=");
|
||||
builder.append(username);
|
||||
builder.append(", displayName=");
|
||||
builder.append(displayName);
|
||||
builder.append(", loginType=");
|
||||
builder.append(loginType);
|
||||
builder.append(", message=");
|
||||
builder.append(message);
|
||||
builder.append(", code=");
|
||||
builder.append(code);
|
||||
builder.append(", provider=");
|
||||
builder.append(provider);
|
||||
builder.append(", sourceIp=");
|
||||
builder.append(sourceIp);
|
||||
builder.append(", ipRegion=");
|
||||
builder.append(ipRegion);
|
||||
builder.append(", ipLocation=");
|
||||
builder.append(ipLocation);
|
||||
builder.append(", browser=");
|
||||
builder.append(browser);
|
||||
builder.append(", platform=");
|
||||
builder.append(platform);
|
||||
builder.append(", application=");
|
||||
builder.append(application);
|
||||
builder.append(", loginUrl=");
|
||||
builder.append(loginUrl);
|
||||
builder.append(", loginTime=");
|
||||
builder.append(loginTime);
|
||||
builder.append(", logoutTime=");
|
||||
builder.append(logoutTime);
|
||||
builder.append(", instId=");
|
||||
builder.append(instId);
|
||||
builder.append(", instName=");
|
||||
builder.append(instName);
|
||||
builder.append(", sessionStatus=");
|
||||
builder.append(sessionStatus);
|
||||
builder.append(", startDate=");
|
||||
builder.append(startDate);
|
||||
builder.append(", endDate=");
|
||||
builder.append(endDate);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +145,8 @@ public class UserInfo extends JpaBaseEntity {
|
||||
protected String lastLogoffTime;
|
||||
protected int passwordSetType;
|
||||
protected Integer loginCount;
|
||||
protected String regionHistory;
|
||||
protected String passwordHistory;
|
||||
|
||||
@Column
|
||||
protected String locale;
|
||||
@@ -1280,6 +1282,22 @@ public class UserInfo extends JpaBaseEntity {
|
||||
this.instName = instName;
|
||||
}
|
||||
|
||||
public String getRegionHistory() {
|
||||
return regionHistory;
|
||||
}
|
||||
|
||||
public void setRegionHistory(String regionHistory) {
|
||||
this.regionHistory = regionHistory;
|
||||
}
|
||||
|
||||
public String getPasswordHistory() {
|
||||
return passwordHistory;
|
||||
}
|
||||
|
||||
public void setPasswordHistory(String passwordHistory) {
|
||||
this.passwordHistory = passwordHistory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
public class LoginHistoryRepository {
|
||||
private static Logger _logger = LoggerFactory.getLogger(LoginHistoryRepository.class);
|
||||
|
||||
private static final String HISTORY_LOGIN_INSERT_STATEMENT = "insert into mxk_history_login (id , sessionid , userid , username , displayname , logintype , message , code , provider , sourceip , browser , platform , application , loginurl , sessionstatus ,instid)values( ? , ? , ? , ? , ? , ? , ?, ? , ? , ?, ? , ? , ?, ? , ? , ?)";
|
||||
private static final String HISTORY_LOGIN_INSERT_STATEMENT = "insert into mxk_history_login (id , sessionid , userid , username , displayname , logintype , message , code , provider , sourceip , ipregion , iplocation, browser , platform , application , loginurl , sessionstatus ,instid)values( ? , ? , ? , ? , ? , ? , ? , ? , ?, ? , ? , ?, ? , ? , ?, ? , ? , ?)";
|
||||
|
||||
private static final String HISTORY_LOGOUT_UPDATE_STATEMENT = "update mxk_history_login set logouttime = ? ,sessionstatus = 7 where sessionid = ?";
|
||||
|
||||
@@ -46,14 +46,15 @@ public class LoginHistoryRepository {
|
||||
new Object[] {
|
||||
historyLogin.getId(), historyLogin.getSessionId(), historyLogin.getUserId(), historyLogin.getUsername(),
|
||||
historyLogin.getDisplayName(), historyLogin.getLoginType(), historyLogin.getMessage(), historyLogin.getCode(),
|
||||
historyLogin.getProvider(), historyLogin.getSourceIp(), historyLogin.getBrowser(), historyLogin.getPlatform(),
|
||||
"Browser", historyLogin.getLoginUrl() , historyLogin.getSessionStatus(),historyLogin.getInstId()
|
||||
historyLogin.getProvider(), historyLogin.getSourceIp(),historyLogin.getIpRegion(),historyLogin.getIpLocation(),
|
||||
historyLogin.getBrowser(), historyLogin.getPlatform(),"Browser", historyLogin.getLoginUrl() ,
|
||||
historyLogin.getSessionStatus(),historyLogin.getInstId()
|
||||
},
|
||||
new int[] {
|
||||
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
|
||||
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
|
||||
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR ,Types.INTEGER,
|
||||
Types.VARCHAR
|
||||
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
|
||||
Types.VARCHAR ,Types.INTEGER, Types.VARCHAR
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -321,6 +321,8 @@ public class LoginRepository {
|
||||
userInfo.setLastLoginIp(rs.getString("lastloginip"));
|
||||
userInfo.setLastLogoffTime(rs.getString("lastlogofftime"));
|
||||
userInfo.setLoginCount(rs.getInt("logincount"));
|
||||
userInfo.setRegionHistory(rs.getString("regionhistory"));
|
||||
userInfo.setPasswordHistory(rs.getString("passwordhistory"));
|
||||
|
||||
userInfo.setTimeZone(rs.getString("timezone"));
|
||||
userInfo.setLocale(rs.getString("locale"));
|
||||
|
||||
@@ -58,7 +58,7 @@ public class WebInstRequestFilter extends GenericFilterBean {
|
||||
if(host.indexOf(":")> -1 ) {
|
||||
host = host.split(":")[0];
|
||||
}
|
||||
Institutions institution =institutionsRepository.findByDomain(host);
|
||||
Institutions institution = institutionsRepository.findByDomain(host);
|
||||
_logger.trace("{}" ,institution);
|
||||
request.getSession().setAttribute(WebConstants.CURRENT_INST, institution);
|
||||
WebContext.setCookie((HttpServletResponse)servletResponse, host, WebConstants.INST_COOKIE_NAME, institution.getId());
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
public abstract class AbstractIpRegion implements IpRegion{
|
||||
|
||||
int failCount = 0;
|
||||
|
||||
public String getLocation(String region) {
|
||||
return region;
|
||||
}
|
||||
|
||||
public int getFailCount() {
|
||||
return failCount;
|
||||
};
|
||||
|
||||
public int plusFailCount() {
|
||||
return failCount++;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
public interface IpRegion {
|
||||
public static final String USERAGENT = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.82 Safari/537.36";
|
||||
|
||||
public static final int TIMEOUT = 5000;
|
||||
|
||||
public String region(String ipAddress);
|
||||
|
||||
public String getLocation(String region);
|
||||
|
||||
public int getFailCount();
|
||||
|
||||
public int plusFailCount() ;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class IpRegionFactory extends AbstractIpRegion implements IpRegion{
|
||||
|
||||
static IpRegionFactory factory = new IpRegionFactory();
|
||||
|
||||
static final ArrayList<IpRegion> ipRegionList;
|
||||
|
||||
static {
|
||||
ipRegionList = new ArrayList<IpRegion>();
|
||||
ipRegionList.add(new IpRegionLocal());
|
||||
ipRegionList.add(new IpRegionIp138());
|
||||
ipRegionList.add(new IpRegionIpchaxun());
|
||||
ipRegionList.add(new IpRegionIpcn());
|
||||
ipRegionList.add(new IpRegionIp360());
|
||||
ipRegionList.add(new IpRegionPconline());
|
||||
}
|
||||
|
||||
public static IpRegion getFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String region(String ipAddress) {
|
||||
for(int i = 0 ; i<ipRegionList.size() ; i++ ) {
|
||||
IpRegion ipRegion = ipRegionList.get(i);
|
||||
String region = ipRegion.region(ipAddress);
|
||||
if(StringUtils.isNotBlank(region)) {
|
||||
return region;
|
||||
}else {
|
||||
if(ipRegion.getFailCount() > 6) {
|
||||
ipRegionList.remove(i);//remove from list
|
||||
}
|
||||
//fail plus 1
|
||||
ipRegion.plusFailCount();
|
||||
}
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
public String getLocation(String region) {
|
||||
if(region.endsWith("电信") || region.endsWith("移动") || region.endsWith("联通")) {
|
||||
region.substring(0, region.length() - 2).trim();
|
||||
}
|
||||
|
||||
if(region.indexOf(" ") > 0) {
|
||||
return region.split(" ")[0];
|
||||
}
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.maxkey.util.JsonUtils;
|
||||
|
||||
public class IpRegionIp138 extends AbstractIpRegion implements IpRegion{
|
||||
|
||||
public static final String REGION_URL = "https://www.ip138.com/iplookup.asp?ip=%s&action=2";
|
||||
|
||||
public static final String BEGIN = "\"ip_c_list\":[";
|
||||
public static final String END = "], \"zg\":1};";
|
||||
|
||||
@Override
|
||||
public String region(String ipAddress) {
|
||||
try {
|
||||
Document doc;
|
||||
doc = Jsoup.connect(String.format(REGION_URL, ipAddress))
|
||||
.timeout(TIMEOUT)
|
||||
.userAgent(USERAGENT)
|
||||
.header("Host", "www.ip138.com")
|
||||
.header("Referer", "https://www.ip138.com/")
|
||||
.header("sec-ch-ua", "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"98\", \"Google Chrome\";v=\"98\"")
|
||||
.header("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")
|
||||
.get();
|
||||
String htmlData = doc.toString();
|
||||
String jsonData = htmlData.substring(htmlData.indexOf(BEGIN) + BEGIN.length() , htmlData.indexOf(END));
|
||||
IpRegionIp138Response responseJson = JsonUtils.json2Object(jsonData, IpRegionIp138Response.class);
|
||||
return responseJson == null ? null : responseJson.toString();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class IpRegionIp138Response {
|
||||
|
||||
String ct;
|
||||
String prov;
|
||||
String city;
|
||||
String area;
|
||||
String yunyin;
|
||||
|
||||
public IpRegionIp138Response() {
|
||||
}
|
||||
public String getCt() {
|
||||
return ct;
|
||||
}
|
||||
public void setCt(String ct) {
|
||||
this.ct = ct;
|
||||
}
|
||||
public String getProv() {
|
||||
return prov;
|
||||
}
|
||||
public void setProv(String prov) {
|
||||
this.prov = prov;
|
||||
}
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
public String getArea() {
|
||||
return area;
|
||||
}
|
||||
public void setArea(String area) {
|
||||
this.area = area;
|
||||
}
|
||||
public String getYunyin() {
|
||||
return yunyin;
|
||||
}
|
||||
public void setYunyin(String yunyin) {
|
||||
this.yunyin = yunyin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(ct)
|
||||
.append(prov)
|
||||
.append(city)
|
||||
.append(area)
|
||||
.append(" ")
|
||||
.append(yunyin);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.maxkey.util.JsonUtils;
|
||||
|
||||
public class IpRegionIp360 extends AbstractIpRegion implements IpRegion{
|
||||
|
||||
public static final String REGION_URL = "http://ip.360.cn/IPQuery/ipquery?ip=%s&verifycode=";
|
||||
public static final String BEGIN = "<body>";
|
||||
public static final String END = "</body>";
|
||||
|
||||
@Override
|
||||
public String region(String ipAddress) {
|
||||
try {
|
||||
Document doc;
|
||||
doc = Jsoup.connect(String.format(REGION_URL, ipAddress))
|
||||
.timeout(TIMEOUT)
|
||||
.userAgent(USERAGENT)
|
||||
.header("Host", "ip.360.cn")
|
||||
.header("Origin", "http://ip.360.cn")
|
||||
.header("Referer", "http://ip.360.cn/")
|
||||
.header("Accept","application/json, text/plain, */*")
|
||||
.post();
|
||||
|
||||
String htmlData = doc.toString();
|
||||
String jsonData = htmlData.substring(htmlData.indexOf(BEGIN) + BEGIN.length() , htmlData.indexOf(END));
|
||||
IpRegionIp360Response responseJson = JsonUtils.json2Object(jsonData, IpRegionIp360Response.class);
|
||||
return responseJson == null ? null : responseJson.getData().replace("\t", " ");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
public class IpRegionIp360Response {
|
||||
|
||||
int errno;
|
||||
String errmsg;
|
||||
String data;
|
||||
public int getErrno() {
|
||||
return errno;
|
||||
}
|
||||
public void setErrno(int errno) {
|
||||
this.errno = errno;
|
||||
}
|
||||
public String getErrmsg() {
|
||||
return errmsg;
|
||||
}
|
||||
public void setErrmsg(String errmsg) {
|
||||
this.errmsg = errmsg;
|
||||
}
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("IpRegionIp360Response [errno=");
|
||||
builder.append(errno);
|
||||
builder.append(", errmsg=");
|
||||
builder.append(errmsg);
|
||||
builder.append(", data=");
|
||||
builder.append(data);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
public class IpRegionIpchaxun extends AbstractIpRegion implements IpRegion{
|
||||
|
||||
public static final String REGION_URL = "https://ipchaxun.com/%s/";
|
||||
|
||||
@Override
|
||||
public String region(String ipAddress) {
|
||||
try {
|
||||
Document doc;
|
||||
doc = Jsoup.connect(String.format(REGION_URL, ipAddress))
|
||||
.timeout(TIMEOUT)
|
||||
.userAgent(USERAGENT)
|
||||
.header("Host","ipchaxun.com")
|
||||
.header("Referer","https://ipchaxun.com/")
|
||||
.header("sec-ch-ua", "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"98\", \"Google Chrome\";v=\"98\"")
|
||||
.header("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")
|
||||
.get();
|
||||
|
||||
Elements address = doc.select(".info label span.value");
|
||||
return address.get(1).text().trim();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
public class IpRegionIpcn extends AbstractIpRegion implements IpRegion{
|
||||
|
||||
public static final String REGION_URL = "https://ip.cn/ip/%s.html";
|
||||
|
||||
@Override
|
||||
public String region(String ipAddress) {
|
||||
try {
|
||||
Document doc;
|
||||
doc = Jsoup.connect(String.format(REGION_URL, ipAddress))
|
||||
.timeout(TIMEOUT)
|
||||
.userAgent(USERAGENT)
|
||||
.header("referer","https://ip.cn/")
|
||||
.header("sec-ch-ua", "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"98\", \"Google Chrome\";v=\"98\"")
|
||||
.get();
|
||||
Elements address = doc.select("#tab0_address");
|
||||
return address.text().trim();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
public class IpRegionLocal extends AbstractIpRegion implements IpRegion{
|
||||
|
||||
@Override
|
||||
public String region(String ipAddress) {
|
||||
if(ipAddress.equals("127.0.0.1") || ipAddress.equals("0:0:0:0:0:0:0:1")) {
|
||||
return "local";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
import org.maxkey.util.JsonUtils;
|
||||
import org.maxkey.web.HttpRequestAdapter;
|
||||
|
||||
public class IpRegionPconline extends AbstractIpRegion implements IpRegion{
|
||||
|
||||
public static final String REGION_URL = "http://whois.pconline.com.cn/ipJson.jsp?json=true&ip=%s";
|
||||
|
||||
@Override
|
||||
public String region(String ipAddress) {
|
||||
String responseJson =
|
||||
new HttpRequestAdapter(HttpRequestAdapter.MediaType.JSON)
|
||||
.get(String.format(REGION_URL,ipAddress),null);
|
||||
return JsonUtils.json2Object(responseJson, IpRegionPconlineResponse.class).getAddr().trim();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class IpRegionPconlineResponse {
|
||||
|
||||
String addr;
|
||||
|
||||
public String getAddr() {
|
||||
return addr;
|
||||
}
|
||||
|
||||
public void setAddr(String addr) {
|
||||
this.addr = addr;
|
||||
}
|
||||
|
||||
public IpRegionPconlineResponse() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class IpRegionFactoryTest {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
System.out.println(IpRegionFactory.getFactory().getLocation(
|
||||
IpRegionFactory.getFactory().region("127.0.0.1")
|
||||
));
|
||||
|
||||
System.out.println(IpRegionFactory.getFactory().getLocation(
|
||||
IpRegionFactory.getFactory().region("117.155.70.59")
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class IpRegionIp138Test {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
IpRegion ipRegion = new IpRegionIp138();
|
||||
System.out.println(ipRegion.region("117.155.70.59"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class IpRegionIp360Test {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
IpRegion ipRegion = new IpRegionIp360();
|
||||
System.out.println(ipRegion.region("117.155.70.59"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class IpRegionIpchaxunTest {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
IpRegion ipRegion = new IpRegionIpchaxun();
|
||||
System.out.println(ipRegion.region("117.155.70.59"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class IpRegionIpcnTest {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
IpRegion ipRegion = new IpRegionIpcn();
|
||||
System.out.println(ipRegion.region("117.155.70.59"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.maxkey.web.ipregion;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class IpRegionPconlineTest {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
IpRegion ipRegion = new IpRegionPconline();
|
||||
System.out.println(ipRegion.region("117.155.70.59"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user