Skip to content

Commit d0fb9dc

Browse files
committed
Update README.md
1 parent 4a5ee0c commit d0fb9dc

File tree

1 file changed

+2
-225
lines changed

1 file changed

+2
-225
lines changed

README.md

Lines changed: 2 additions & 225 deletions
Original file line numberDiff line numberDiff line change
@@ -5,231 +5,8 @@ This component allows user to query an IP address if it was being used as VPN an
55
* Free IP2Proxy BIN Data: https://lite.ip2location.com
66
* Commercial IP2Proxy BIN Data: https://www.ip2location.com/database/ip2proxy
77

8-
As an alternative, this component can also call the IP2Proxy Web Service. This requires an API key. If you don't have an existing API key, you can subscribe for one at the below:
9-
10-
https://www.ip2location.com/web-service/ip2proxy
11-
12-
## Compilation
13-
14-
```bash
15-
javac com/ip2proxy/*.java
16-
jar cf ip2proxy.jar com/ip2proxy/*.class
17-
```
18-
19-
## QUERY USING THE BIN FILE
20-
21-
## Methods
22-
Below are the methods supported in this class.
23-
24-
|Method Name|Description|
25-
|---|---|
26-
|Open|Open the IP2Proxy BIN data for lookup. Please see the **Usage** section of the 2 modes supported to load the BIN data file.|
27-
|Close|Close and clean up the file pointer.|
28-
|GetPackageVersion|Get the package version (1 to 11 for PX1 to PX11 respectively).|
29-
|GetModuleVersion|Get the module version.|
30-
|GetDatabaseVersion|Get the database version.|
31-
|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>|
32-
|GetAll|Return the proxy information in an object.|
33-
|GetProxyType|Return the proxy type. Please visit <a href="https://www.ip2location.com/database/px10-ip-proxytype-country-region-city-isp-domain-usagetype-asn-lastseen-threat-residential" target="_blank">IP2Location</a> for the list of proxy types supported|
34-
|GetCountryShort|Return the ISO3166-1 country code (2-digits) of the proxy.|
35-
|GetCountryLong|Return the ISO3166-1 country name of the proxy.|
36-
|GetRegion|Return the ISO3166-2 region name of the proxy. Please visit <a href="https://www.ip2location.com/free/iso3166-2" target="_blank">ISO3166-2 Subdivision Code</a> for the information of ISO3166-2 supported|
37-
|GetCity|Return the city name of the proxy.|
38-
|GetISP|Return the ISP name of the proxy.|
39-
|GetDomain|Return the domain name of the proxy.|
40-
|GetUsageType|Return the usage type classification of the proxy. Please visit <a href="https://www.ip2location.com/database/px10-ip-proxytype-country-region-city-isp-domain-usagetype-asn-lastseen-threat-residential" target="_blank">IP2Location</a> for the list of usage types supported.|
41-
|GetASN|Return the autonomous system number of the proxy.|
42-
|GetAS|Return the autonomous system name of the proxy.|
43-
|GetLastSeen|Return the number of days that the proxy was last seen.|
44-
|GetThreat|Return the threat type of the proxy.|
45-
|GetProvider|Return the provider of the proxy.|
46-
47-
## Usage
48-
49-
Open and read IP2Proxy binary database. There are 2 modes:
50-
51-
1. **IOModes.IP2PROXY_FILE_IO** - File I/O reading. Slower lookup, but low resource consuming. This is the default.
52-
2. **IOModes.IP2PROXY_MEMORY_MAPPED** - Stores whole IP2Proxy database into a memory-mapped file. Extremely resources consuming. Do not use this mode if your system do not have enough memory.
53-
54-
```java
55-
import com.ip2proxy.*;
56-
57-
public class Main {
58-
public Main() {
59-
}
60-
61-
public static void main(String[] args) {
62-
try {
63-
IP2Proxy Proxy = new IP2Proxy();
64-
ProxyResult All;
65-
66-
int IsProxy;
67-
String ProxyType;
68-
String CountryShort;
69-
String CountryLong;
70-
String Region;
71-
String City;
72-
String ISP;
73-
String Domain;
74-
String UsageType;
75-
String ASN;
76-
String AS;
77-
String LastSeen;
78-
String Threat;
79-
String Provider;
80-
81-
String IP = "221.121.146.0";
82-
83-
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) {
84-
System.out.println("GetModuleVersion: " + Proxy.GetModuleVersion());
85-
System.out.println("GetPackageVersion: " + Proxy.GetPackageVersion());
86-
System.out.println("GetDatabaseVersion: " + Proxy.GetDatabaseVersion());
87-
88-
// reading all available fields
89-
All = Proxy.GetAll(IP);
90-
System.out.println("Is_Proxy: " + String.valueOf(All.Is_Proxy));
91-
System.out.println("Proxy_Type: " + All.Proxy_Type);
92-
System.out.println("Country_Short: " + All.Country_Short);
93-
System.out.println("Country_Long: " + All.Country_Long);
94-
System.out.println("Region: " + All.Region);
95-
System.out.println("City: " + All.City);
96-
System.out.println("ISP: " + All.ISP);
97-
System.out.println("Domain: " + All.Domain);
98-
System.out.println("Usage_Type: " + All.Usage_Type);
99-
System.out.println("ASN: " + All.ASN);
100-
System.out.println("AS: " + All.AS);
101-
System.out.println("Last_Seen: " + All.Last_Seen);
102-
System.out.println("Threat: " + All.Threat);
103-
System.out.println("Provider: " + All.Provider);
104-
105-
// reading individual fields
106-
IsProxy = Proxy.IsProxy(IP);
107-
System.out.println("Is_Proxy: " + String.valueOf(IsProxy));
108-
109-
ProxyType = Proxy.GetProxyType(IP);
110-
System.out.println("Proxy_Type: " + ProxyType);
111-
112-
CountryShort = Proxy.GetCountryShort(IP);
113-
System.out.println("Country_Short: " + CountryShort);
114-
115-
CountryLong = Proxy.GetCountryLong(IP);
116-
System.out.println("Country_Long: " + CountryLong);
117-
118-
Region = Proxy.GetRegion(IP);
119-
System.out.println("Region: " + Region);
120-
121-
City = Proxy.GetCity(IP);
122-
System.out.println("City: " + City);
123-
124-
ISP = Proxy.GetISP(IP);
125-
System.out.println("ISP: " + ISP);
126-
127-
Domain = Proxy.GetDomain(IP);
128-
System.out.println("Domain: " + Domain);
129-
130-
UsageType = Proxy.GetUsageType(IP);
131-
System.out.println("UsageType: " + UsageType);
132-
133-
ASN = Proxy.GetASN(IP);
134-
System.out.println("ASN: " + ASN);
135-
136-
AS = Proxy.GetAS(IP);
137-
System.out.println("AS: " + AS);
138-
139-
LastSeen = Proxy.GetLastSeen(IP);
140-
System.out.println("LastSeen: " + LastSeen);
141-
142-
Threat = Proxy.GetThreat(IP);
143-
System.out.println("Threat: " + Threat);
144-
145-
Provider = Proxy.GetProvider(IP);
146-
System.out.println("Provider: " + Provider);
147-
}
148-
else {
149-
System.out.println("Error reading BIN file.");
150-
}
151-
Proxy.Close();
152-
}
153-
catch(Exception e) {
154-
System.out.println(e);
155-
}
156-
}
157-
}
158-
```
159-
160-
## QUERY USING THE IP2PROXY PROXY DETECTION WEB SERVICE
161-
162-
## Methods
163-
Below are the methods supported in this class.
164-
165-
|Method Name|Description|
166-
|---|---|
167-
|Open(String APIKey, String Package, boolean UseSSL)| Expects 3 input parameters:<ol><li>IP2Proxy API Key.</li><li>Package (PX1 - PX11)</li></li><li>Use HTTPS or HTTP</li></ol>|
168-
|IPQuery(String IPAddress)|Query IP address. This method returns a JsonObject containing the proxy info. <ul><li>countryCode</li><li>countryName</li><li>regionName</li><li>cityName</li><li>isp</li><li>domain</li><li>usageType</li><li>asn</li><li>as</li><li>lastSeen</li><li>threat</li><li>proxyType</li><li>isProxy</li><li>provider</li><ul>|
169-
|GetCredit()|This method returns the web service credit balance in a JsonObject.|
170-
171-
## Usage
172-
173-
```java
174-
import com.ip2proxy.*;
175-
import com.google.gson.*;
176-
177-
public class Main {
178-
public Main() {
179-
}
180-
181-
public static void main(String[] args) {
182-
try
183-
{
184-
IP2ProxyWebService ws = new IP2ProxyWebService();
185-
186-
String strIPAddress = "8.8.8.8";
187-
String strAPIKey = "YOUR_API_KEY";
188-
String strPackage = "PX11";
189-
boolean boolSSL = true;
190-
191-
ws.Open(strAPIKey, strPackage, boolSSL);
192-
193-
JsonObject myresult = ws.IPQuery(strIPAddress);
194-
195-
if ((myresult.get("response") != null) && (myresult.get("response").getAsString().equals("OK")))
196-
{
197-
System.out.println("countryCode: " + ((myresult.get("countryCode") != null) ? myresult.get("countryCode").getAsString() : ""));
198-
System.out.println("countryName: " + ((myresult.get("countryName") != null) ? myresult.get("countryName").getAsString() : ""));
199-
System.out.println("regionName: " + ((myresult.get("regionName") != null) ? myresult.get("regionName").getAsString() : ""));
200-
System.out.println("cityName: " + ((myresult.get("cityName") != null) ? myresult.get("cityName").getAsString() : ""));
201-
System.out.println("isp: " + ((myresult.get("isp") != null) ? myresult.get("isp").getAsString() : ""));
202-
System.out.println("domain: " + ((myresult.get("domain") != null) ? myresult.get("domain").getAsString() : ""));
203-
System.out.println("usageType: " + ((myresult.get("usageType") != null) ? myresult.get("usageType").getAsString() : ""));
204-
System.out.println("asn: " + ((myresult.get("asn") != null) ? myresult.get("asn").getAsString() : ""));
205-
System.out.println("as: " + ((myresult.get("as") != null) ? myresult.get("as").getAsString() : ""));
206-
System.out.println("lastSeen: " + ((myresult.get("lastSeen") != null) ? myresult.get("lastSeen").getAsString() : ""));
207-
System.out.println("proxyType: " + ((myresult.get("proxyType") != null) ? myresult.get("proxyType").getAsString() : ""));
208-
System.out.println("threat: " + ((myresult.get("threat") != null) ? myresult.get("threat").getAsString() : ""));
209-
System.out.println("isProxy: " + ((myresult.get("isProxy") != null) ? myresult.get("isProxy").getAsString() : ""));
210-
System.out.println("provider: " + ((myresult.get("provider") != null) ? myresult.get("provider").getAsString() : ""));
211-
}
212-
else if (myresult.get("response") != null)
213-
{
214-
System.out.println("Error: " + myresult.get("response").getAsString());
215-
}
216-
217-
myresult = ws.GetCredit();
218-
219-
if (myresult.get("response") != null)
220-
{
221-
System.out.println("Credit balance: " + myresult.get("response").getAsString());
222-
}
223-
}
224-
catch(Exception e)
225-
{
226-
System.out.println(e);
227-
e.printStackTrace(System.out);
228-
}
229-
230-
}
231-
}
232-
```
8+
## Developer Documentation
9+
To learn more about installation, usage, and code examples, please visit the developer documentation at [https://ip2proxy-java.readthedocs.io/en/latest/index.html.](https://ip2proxy-java.readthedocs.io/en/latest/index.html)
23310

23411
### Proxy Type
23512

0 commit comments

Comments
 (0)