Skip to content

Commit c8f8130

Browse files
Added support for district, ASN and AS
1 parent adf0d22 commit c8f8130

File tree

9 files changed

+127
-49
lines changed

9 files changed

+127
-49
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 IP2Location
3+
Copyright (c) 2023 IP2Location
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# IP2Location IP Geolocation Java Component
22

3-
This IP Geolocation Java component allows user to query an IP address for info such as the visitor’s country, region, city, ISP or company name. In addition, users can also determine extra useful geolocation information such as latitude, longitude, ZIP code, domain name, time zone, connection speed, IDD code, area code, weather station code, weather station name, MCC, MNC, mobile brand name, elevation, usage type, address type & IAB category. It lookup the IP address from **IP2Location BIN Data** file. This data file can be downloaded at
3+
This IP Geolocation Java component allows user to query an IP address for info such as the visitor’s country, region, city, ISP or company name. In addition, users can also determine extra useful geolocation information such as latitude, longitude, ZIP code, domain name, time zone, connection speed, IDD code, area code, weather station code, weather station name, MCC, MNC, mobile brand name, elevation, usage type, address type, IAB category, district, autonomous system number (ASN) and autonomous system (AS). It lookup the IP address from **IP2Location BIN Data** file. This data file can be downloaded at
44

55
* Free IP2Location IP Geolocation BIN Data: https://lite.ip2location.com
66
* Commercial IP2Location IP Geolocation BIN Data: https://www.ip2location.com/database/ip2location
@@ -64,6 +64,9 @@ Below are the result methods.
6464
|getUsageType|Usage type classification of ISP or company:<ul><li>(COM) Commercial</li><li>(ORG) Organization</li><li>(GOV) Government</li><li>(MIL) Military</li><li>(EDU) University/College/School</li><li>(LIB) Library</li><li>(CDN) Content Delivery Network</li><li>(ISP) Fixed Line ISP</li><li>(MOB) Mobile ISP</li><li>(DCH) Data Center/Web Hosting/Transit</li><li>(SES) Search Engine Spider</li><li>(RSV) Reserved</li></ul>|
6565
|getAddressType|IP address types as defined in Internet Protocol version 4 (IPv4) and Internet Protocol version 6 (IPv6).<ul><li>(A) Anycast - One to the closest</li><li>(U) Unicast - One to one</li><li>(M) Multicast - One to multiple</li><li>(B) Broadcast - One to all</li></ul>|
6666
|getCategory|The domain category is based on [IAB Tech Lab Content Taxonomy](https://www.ip2location.com/free/iab-categories). These categories are comprised of Tier-1 and Tier-2 (if available) level categories widely used in services like advertising, Internet security and filtering appliances.|
67+
|getDistrict|District.|
68+
|getASN|Autonomous System Number.|
69+
|getAS|Autonomous System.|
6770
|getStatus|Status code of query.|
6871

6972
## Status codes
@@ -93,7 +96,7 @@ public class Main
9396
try
9497
{
9598
String ip = "8.8.8.8";
96-
String binfile = "/usr/data/IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-ADDRESSTYPE-CATEGORY.BIN";
99+
String binfile = "/usr/data/IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-ADDRESSTYPE-CATEGORY-DISTRICT-ASN.BIN";
97100

98101
IP2Location loc = new IP2Location();
99102

com/ip2location/Country.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@
1313
/**
1414
* This class parses country information CSV and returns the country information.
1515
* <p>
16-
* <b>Requirements:</b> Java SDK 1.4 or later<br>
17-
* <p>
18-
* Copyright (c) 2002-2022 IP2Location.com
16+
* Copyright (c) 2002-2023 IP2Location.com
1917
* <p>
2018
*
2119
* @author IP2Location.com
22-
* @version 8.10.0
20+
* @version 8.11.0
2321
*/
2422
public class Country {
2523
private final Map<String, Map<String, String>> records = new HashMap<>();

com/ip2location/IP2Location.java

Lines changed: 56 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@
3030
* <li>And much, much more!</li>
3131
* </ul>
3232
* <p>
33-
* <b>Requirements:</b> Java SDK 1.4 or later<br>
34-
* <p>
35-
* Copyright (c) 2002-2022 IP2Location.com
33+
* Copyright (c) 2002-2023 IP2Location.com
3634
* <p>
3735
*
3836
* @author IP2Location.com
39-
* @version 8.10.0
37+
* @version 8.11.0
4038
*/
4139
public class IP2Location {
4240
private static final Pattern pattern = Pattern.compile("^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"); // IPv4
@@ -53,27 +51,30 @@ public class IP2Location {
5351
private static final BigInteger TO_TEREDO = new BigInteger("42540488241204005274814694018844196863");
5452
private static final BigInteger LAST_32BITS = new BigInteger("4294967295");
5553

56-
private static final int[] COUNTRY_POSITION = {0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
57-
private static final int[] REGION_POSITION = {0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3};
58-
private static final int[] CITY_POSITION = {0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4};
59-
private static final int[] ISP_POSITION = {0, 0, 3, 0, 5, 0, 7, 5, 7, 0, 8, 0, 9, 0, 9, 0, 9, 0, 9, 7, 9, 0, 9, 7, 9, 9};
60-
private static final int[] LATITUDE_POSITION = {0, 0, 0, 0, 0, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5};
61-
private static final int[] LONGITUDE_POSITION = {0, 0, 0, 0, 0, 6, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6};
62-
private static final int[] DOMAIN_POSITION = {0, 0, 0, 0, 0, 0, 0, 6, 8, 0, 9, 0, 10, 0, 10, 0, 10, 0, 10, 8, 10, 0, 10, 8, 10, 10};
63-
private static final int[] ZIPCODE_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 7, 7, 7, 0, 7, 0, 7, 7, 7, 0, 7, 7};
64-
private static final int[] TIMEZONE_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 7, 8, 8, 8, 7, 8, 0, 8, 8, 8, 0, 8, 8};
65-
private static final int[] NETSPEED_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 11, 0, 11, 8, 11, 0, 11, 0, 11, 0, 11, 11};
66-
private static final int[] IDDCODE_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 12, 0, 12, 0, 12, 9, 12, 0, 12, 12};
67-
private static final int[] AREACODE_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 13, 0, 13, 0, 13, 10, 13, 0, 13, 13};
68-
private static final int[] WEATHERSTATIONCODE_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 14, 0, 14, 0, 14, 0, 14, 14};
69-
private static final int[] WEATHERSTATIONNAME_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 15, 0, 15, 0, 15, 0, 15, 15};
70-
private static final int[] MCC_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 16, 0, 16, 9, 16, 16};
71-
private static final int[] MNC_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 17, 0, 17, 10, 17, 17};
72-
private static final int[] MOBILEBRAND_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 18, 0, 18, 11, 18, 18};
73-
private static final int[] ELEVATION_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 19, 0, 19, 19};
74-
private static final int[] USAGETYPE_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 20, 20};
75-
private static final int[] ADDRESSTYPE_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21};
76-
private static final int[] CATEGORY_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22};
54+
private static final int[] COUNTRY_POSITION = {0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
55+
private static final int[] REGION_POSITION = {0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3};
56+
private static final int[] CITY_POSITION = {0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4};
57+
private static final int[] ISP_POSITION = {0, 0, 3, 0, 5, 0, 7, 5, 7, 0, 8, 0, 9, 0, 9, 0, 9, 0, 9, 7, 9, 0, 9, 7, 9, 9, 9};
58+
private static final int[] LATITUDE_POSITION = {0, 0, 0, 0, 0, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5};
59+
private static final int[] LONGITUDE_POSITION = {0, 0, 0, 0, 0, 6, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6};
60+
private static final int[] DOMAIN_POSITION = {0, 0, 0, 0, 0, 0, 0, 6, 8, 0, 9, 0, 10, 0, 10, 0, 10, 0, 10, 8, 10, 0, 10, 8, 10, 10, 10};
61+
private static final int[] ZIPCODE_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 7, 7, 7, 0, 7, 0, 7, 7, 7, 0, 7, 7, 7};
62+
private static final int[] TIMEZONE_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 7, 8, 8, 8, 7, 8, 0, 8, 8, 8, 0, 8, 8, 8};
63+
private static final int[] NETSPEED_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 11, 0, 11, 8, 11, 0, 11, 0, 11, 0, 11, 11, 11};
64+
private static final int[] IDDCODE_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 12, 0, 12, 0, 12, 9, 12, 0, 12, 12, 12};
65+
private static final int[] AREACODE_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 13, 0, 13, 0, 13, 10, 13, 0, 13, 13, 13};
66+
private static final int[] WEATHERSTATIONCODE_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 14, 0, 14, 0, 14, 0, 14, 14, 14};
67+
private static final int[] WEATHERSTATIONNAME_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 15, 0, 15, 0, 15, 0, 15, 15, 15};
68+
private static final int[] MCC_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 16, 0, 16, 9, 16, 16, 16};
69+
private static final int[] MNC_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 17, 0, 17, 10, 17, 17, 17};
70+
private static final int[] MOBILEBRAND_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 18, 0, 18, 11, 18, 18, 18};
71+
private static final int[] ELEVATION_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 19, 0, 19, 19, 19};
72+
private static final int[] USAGETYPE_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 20, 20, 20};
73+
private static final int[] ADDRESSTYPE_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21};
74+
private static final int[] CATEGORY_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 22};
75+
private static final int[] DISTRICT_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23};
76+
private static final int[] ASN_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24};
77+
private static final int[] AS_POSITION = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25};
7778
static final DecimalFormat GEO_COORDINATE_FORMAT;
7879
static {
7980
DecimalFormatSymbols symbols = new DecimalFormatSymbols();
@@ -125,6 +126,9 @@ public class IP2Location {
125126
private int USAGETYPE_POSITION_OFFSET;
126127
private int ADDRESSTYPE_POSITION_OFFSET;
127128
private int CATEGORY_POSITION_OFFSET;
129+
private int DISTRICT_POSITION_OFFSET;
130+
private int ASN_POSITION_OFFSET;
131+
private int AS_POSITION_OFFSET;
128132
private boolean COUNTRY_ENABLED;
129133
private boolean REGION_ENABLED;
130134
private boolean CITY_ENABLED;
@@ -146,6 +150,9 @@ public class IP2Location {
146150
private boolean USAGETYPE_ENABLED;
147151
private boolean ADDRESSTYPE_ENABLED;
148152
private boolean CATEGORY_ENABLED;
153+
private boolean DISTRICT_ENABLED;
154+
private boolean ASN_ENABLED;
155+
private boolean AS_ENABLED;
149156

150157
public IP2Location() {
151158

@@ -366,6 +373,9 @@ private boolean LoadBIN() throws IOException {
366373
USAGETYPE_POSITION_OFFSET = (USAGETYPE_POSITION[dbtype] != 0) ? (USAGETYPE_POSITION[dbtype] - 2) << 2 : 0;
367374
ADDRESSTYPE_POSITION_OFFSET = (ADDRESSTYPE_POSITION[dbtype] != 0) ? (ADDRESSTYPE_POSITION[dbtype] - 2) << 2 : 0;
368375
CATEGORY_POSITION_OFFSET = (CATEGORY_POSITION[dbtype] != 0) ? (CATEGORY_POSITION[dbtype] - 2) << 2 : 0;
376+
DISTRICT_POSITION_OFFSET = (DISTRICT_POSITION[dbtype] != 0) ? (DISTRICT_POSITION[dbtype] - 2) << 2 : 0;
377+
ASN_POSITION_OFFSET = (ASN_POSITION[dbtype] != 0) ? (ASN_POSITION[dbtype] - 2) << 2 : 0;
378+
AS_POSITION_OFFSET = (AS_POSITION[dbtype] != 0) ? (AS_POSITION[dbtype] - 2) << 2 : 0;
369379

370380
COUNTRY_ENABLED = (COUNTRY_POSITION[dbtype] != 0);
371381
REGION_ENABLED = (REGION_POSITION[dbtype] != 0);
@@ -388,6 +398,9 @@ private boolean LoadBIN() throws IOException {
388398
USAGETYPE_ENABLED = (USAGETYPE_POSITION[dbtype] != 0);
389399
ADDRESSTYPE_ENABLED = (ADDRESSTYPE_POSITION[dbtype] != 0);
390400
CATEGORY_ENABLED = (CATEGORY_POSITION[dbtype] != 0);
401+
DISTRICT_ENABLED = (DISTRICT_POSITION[dbtype] != 0);
402+
ASN_ENABLED = (ASN_POSITION[dbtype] != 0);
403+
AS_ENABLED = (AS_POSITION[dbtype] != 0);
391404

392405
if (_MetaData.getIndexed()) {
393406
int readLen = _IndexArrayIPv4.length;
@@ -721,6 +734,24 @@ public IPResult IPQuery(String IPAddress) throws IOException {
721734
} else {
722735
record.category = IPResult.NOT_SUPPORTED;
723736
}
737+
if (DISTRICT_ENABLED) {
738+
position = read32Row(row, DISTRICT_POSITION_OFFSET).longValue();
739+
record.district = readStr(position, mydatabuffer, filehandle);
740+
} else {
741+
record.district = IPResult.NOT_SUPPORTED;
742+
}
743+
if (ASN_ENABLED) {
744+
position = read32Row(row, ASN_POSITION_OFFSET).longValue();
745+
record.asn = readStr(position, mydatabuffer, filehandle);
746+
} else {
747+
record.asn = IPResult.NOT_SUPPORTED;
748+
}
749+
if (AS_ENABLED) {
750+
position = read32Row(row, AS_POSITION_OFFSET).longValue();
751+
record.as = readStr(position, mydatabuffer, filehandle);
752+
} else {
753+
record.as = IPResult.NOT_SUPPORTED;
754+
}
724755
record.status = "OK";
725756
break;
726757
} else {

com/ip2location/IP2LocationWebService.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@
2222
* <li>And much, much more!</li>
2323
* </ul>
2424
* <p>
25-
* <b>Requirements:</b> Java SDK 1.4 or later<br>
26-
* <p>
27-
* Copyright (c) 2002-2022 IP2Location.com
25+
* Copyright (c) 2002-2023 IP2Location.com
2826
* <p>
2927
*
3028
* @author IP2Location.com
31-
* @version 8.10.0
29+
* @version 8.11.0
3230
*/
3331
public class IP2LocationWebService {
3432
private static final Pattern pattern = Pattern.compile("^[\\dA-Z]{10}$");

com/ip2location/IPResult.java

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
/**
44
* This class is used to store the geolocation data that is returned by the IP2Location class.
55
* <p>
6-
* <b>Requirements:</b> Java SDK 1.4 or later<br>
7-
* <p>
8-
* Copyright (c) 2002-2022 IP2Location.com
6+
* Copyright (c) 2002-2023 IP2Location.com
97
* <p>
108
*
119
* @author IP2Location.com
12-
* @version 8.10.0
10+
* @version 8.11.0
1311
*/
1412
public class IPResult {
1513
static final String NOT_SUPPORTED = "Not_Supported";
@@ -36,9 +34,12 @@ public class IPResult {
3634
String usagetype;
3735
String addresstype;
3836
String category;
37+
String district;
38+
String asn;
39+
String as;
3940
String status;
4041
boolean delay = false;
41-
String version = "Version 8.10.0";
42+
String version = "Version 8.11.0";
4243

4344
IPResult(String ipstring) {
4445
ip_address = ipstring;
@@ -242,6 +243,33 @@ public String getCategory() {
242243
return category;
243244
}
244245

246+
/**
247+
* This method to get district.
248+
*
249+
* @return the district.
250+
*/
251+
public String getDistrict() {
252+
return district;
253+
}
254+
255+
/**
256+
* This method to get autonomous system number (ASN).
257+
*
258+
* @return the ASN.
259+
*/
260+
public String getASN() {
261+
return asn;
262+
}
263+
264+
/**
265+
* This method to get autonomous system (AS).
266+
*
267+
* @return the AS.
268+
*/
269+
public String getAS() {
270+
return as;
271+
}
272+
245273
/**
246274
* This method to get status code of query.
247275
*
@@ -300,6 +328,9 @@ public String toString() {
300328
buf.append("\tUsageType = " + usagetype + NL);
301329
buf.append("\tAddressType = " + addresstype + NL);
302330
buf.append("\tCategory = " + category + NL);
331+
buf.append("\tDistrict = " + district + NL);
332+
buf.append("\tASN = " + asn + NL);
333+
buf.append("\tAS = " + as + NL);
303334
return buf.toString();
304335
}
305336
}

com/ip2location/IPTools.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@
2828
* <li>Converts CIDR to IPv6 range</li>
2929
* </ul>
3030
* <p>
31-
* <b>Requirements:</b> Java SDK 1.4 or later<br>
32-
* <p>
33-
* Copyright (c) 2002-2022 IP2Location.com
31+
* Copyright (c) 2002-2023 IP2Location.com
3432
* <p>
3533
*
3634
* @author IP2Location.com
37-
* @version 8.10.0
35+
* @version 8.11.0
3836
*/
3937
public class IPTools {
4038
private static final BigInteger MAX_IPV4_RANGE = new BigInteger("4294967295");

com/ip2location/Region.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010
/**
1111
* This class parses region information CSV and returns the region code.
1212
* <p>
13-
* <b>Requirements:</b> Java SDK 1.4 or later<br>
14-
* <p>
15-
* Copyright (c) 2002-2022 IP2Location.com
13+
* Copyright (c) 2002-2023 IP2Location.com
1614
* <p>
1715
*
1816
* @author IP2Location.com
19-
* @version 8.10.0
17+
* @version 8.11.0
2018
*/
2119
public class Region {
2220
private final Map<String, List<Map<String, String>>> records = new HashMap<>();

test/java/IP2LocationTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,27 @@ void TestQueryCategory() throws IOException {
196196
assertEquals(rec.getCategory(), "Not_Supported");
197197
}
198198

199+
@Test
200+
void TestQueryDistrict() throws IOException {
201+
loc.Open(binfilepath);
202+
IPResult rec = loc.IPQuery(ip);
203+
assertEquals(rec.getDistrict(), "Not_Supported");
204+
}
205+
206+
@Test
207+
void TestQueryASN() throws IOException {
208+
loc.Open(binfilepath);
209+
IPResult rec = loc.IPQuery(ip);
210+
assertEquals(rec.getASN(), "Not_Supported");
211+
}
212+
213+
@Test
214+
void TestQueryAS() throws IOException {
215+
loc.Open(binfilepath);
216+
IPResult rec = loc.IPQuery(ip);
217+
assertEquals(rec.getAS(), "Not_Supported");
218+
}
219+
199220
@AfterEach
200221
void TearDown() {
201222
loc.Close();

0 commit comments

Comments
 (0)