Skip to content

Commit efc06c5

Browse files
committed
Added provider field and exception handling for incorrect BIN database.
1 parent 551bc73 commit efc06c5

File tree

4 files changed

+1246
-1249
lines changed

4 files changed

+1246
-1249
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Below are the methods supported in this class.
1919
|---|---|
2020
|Open|Open the IP2Proxy BIN data for lookup. Please see the **Usage** section of the 2 modes supported to load the BIN data file.|
2121
|Close|Close and clean up the file pointer.|
22-
|GetPackageVersion|Get the package version (1 to 10 for PX1 to PX10 respectively).|
22+
|GetPackageVersion|Get the package version (1 to 11 for PX1 to PX11 respectively).|
2323
|GetModuleVersion|Get the module version.|
2424
|GetDatabaseVersion|Get the database version.|
2525
|IsProxy|Check whether if an IP address was a proxy. Returned value:<ul><li>-1 : errors</li><li>0 : not a proxy</li><li>1 : a proxy</li><li>2 : a data center IP address or search engine robot</li></ul>|
@@ -36,6 +36,7 @@ Below are the methods supported in this class.
3636
|GetAS|Return the autonomous system name of the proxy.|
3737
|GetLastSeen|Return the number of days that the proxy was last seen.|
3838
|GetThreat|Return the threat type of the proxy.|
39+
|GetProvider|Return the provider of the proxy.|
3940

4041
## Usage
4142

@@ -69,10 +70,11 @@ public class Main {
6970
String AS;
7071
String LastSeen;
7172
String Threat;
73+
String Provider;
7274

7375
String IP = "221.121.146.0";
7476

75-
if (Proxy.Open("/usr/data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL.BIN", IP2Proxy.IOModes.IP2PROXY_MEMORY_MAPPED) == 0) {
77+
if (Proxy.Open("/usr/data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER.BIN", IP2Proxy.IOModes.IP2PROXY_MEMORY_MAPPED) == 0) {
7678
System.out.println("GetModuleVersion: " + Proxy.GetModuleVersion());
7779
System.out.println("GetPackageVersion: " + Proxy.GetPackageVersion());
7880
System.out.println("GetDatabaseVersion: " + Proxy.GetDatabaseVersion());
@@ -92,6 +94,7 @@ public class Main {
9294
System.out.println("AS: " + All.AS);
9395
System.out.println("Last_Seen: " + All.Last_Seen);
9496
System.out.println("Threat: " + All.Threat);
97+
System.out.println("Provider: " + All.Provider);
9598

9699
// reading individual fields
97100
IsProxy = Proxy.IsProxy(IP);
@@ -132,6 +135,9 @@ public class Main {
132135

133136
Threat = Proxy.GetThreat(IP);
134137
System.out.println("Threat: " + Threat);
138+
139+
Provider = Proxy.GetProvider(IP);
140+
System.out.println("Provider: " + Provider);
135141
}
136142
else {
137143
System.out.println("Error reading BIN file.");

0 commit comments

Comments
 (0)