|
1 | | -IP2Proxy Java Component |
2 | | -======================= |
3 | | - |
4 | | -This is the Java component to lookup IP2Proxy databases from https://www.ip2location.com/proxy-database |
5 | | - |
6 | | -IP2Proxy Database contains IP addresses which are used as VPN anonymizer, open proxies, web proxies and Tor exits. The database includes records for all public IPv4 addresses. |
7 | | - |
8 | | - |
9 | | -Compilation |
10 | | -=========== |
11 | | -```bash |
12 | | -javac com/ip2proxy/*.java |
13 | | -jar cf ip2proxy.jar com/ip2proxy/*.class |
14 | | -``` |
15 | | - |
16 | | -Sample Code |
17 | | -=========== |
18 | | -```java |
19 | | -import com.ip2proxy.*; |
20 | | - |
21 | | -public class Main { |
22 | | - public Main() { |
23 | | - } |
24 | | - |
25 | | - public static void main(String[] args) { |
26 | | - try { |
27 | | - IP2Proxy Proxy = new IP2Proxy(); |
28 | | - ProxyResult All; |
29 | | - |
30 | | - int IsProxy; |
31 | | - String ProxyType; |
32 | | - String CountryShort; |
33 | | - String CountryLong; |
34 | | - String Region; |
35 | | - String City; |
36 | | - String ISP; |
37 | | - |
38 | | - String IP = "221.121.146.0"; |
39 | | - |
40 | | - if (Proxy.Open("C:\\DATA\\IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.BIN", IP2Proxy.IOModes.IP2PROXY_MEMORY_MAPPED) == 0) { |
41 | | - System.out.println("GetModuleVersion: " + Proxy.GetModuleVersion()); |
42 | | - System.out.println("GetPackageVersion: " + Proxy.GetPackageVersion()); |
43 | | - System.out.println("GetDatabaseVersion: " + Proxy.GetDatabaseVersion()); |
44 | | - |
45 | | - // reading all available fields |
46 | | - All = Proxy.GetAll(IP); |
47 | | - System.out.println("Is_Proxy: " + String.valueOf(All.Is_Proxy)); |
48 | | - System.out.println("Proxy_Type: " + All.Proxy_Type); |
49 | | - System.out.println("Country_Short: " + All.Country_Short); |
50 | | - System.out.println("Country_Long: " + All.Country_Long); |
51 | | - System.out.println("Region: " + All.Region); |
52 | | - System.out.println("City: " + All.City); |
53 | | - System.out.println("ISP: " + All.ISP); |
54 | | - |
55 | | - // reading individual fields |
56 | | - IsProxy = Proxy.IsProxy(IP); |
57 | | - System.out.println("Is_Proxy: " + String.valueOf(IsProxy)); |
58 | | - |
59 | | - ProxyType = Proxy.GetProxyType(IP); |
60 | | - System.out.println("Proxy_Type: " + ProxyType); |
61 | | - |
62 | | - CountryShort = Proxy.GetCountryShort(IP); |
63 | | - System.out.println("Country_Short: " + CountryShort); |
64 | | - |
65 | | - CountryLong = Proxy.GetCountryLong(IP); |
66 | | - System.out.println("Country_Long: " + CountryLong); |
67 | | - |
68 | | - Region = Proxy.GetRegion(IP); |
69 | | - System.out.println("Region: " + Region); |
70 | | - |
71 | | - City = Proxy.GetCity(IP); |
72 | | - System.out.println("City: " + City); |
73 | | - |
74 | | - ISP = Proxy.GetISP(IP); |
75 | | - System.out.println("ISP: " + ISP); |
76 | | - } |
77 | | - else { |
78 | | - System.out.println("Error reading BIN file."); |
79 | | - } |
80 | | - Proxy.Close(); |
81 | | - } |
82 | | - catch(Exception Ex) { |
83 | | - System.out.println(Ex); |
84 | | - } |
85 | | - } |
86 | | -} |
87 | | -``` |
88 | | - |
| 1 | +IP2Proxy Java Component |
| 2 | +======================= |
| 3 | + |
| 4 | +This is the Java component to lookup IP2Proxy databases from https://www.ip2location.com/proxy-database |
| 5 | + |
| 6 | +IP2Proxy Database contains IP addresses which are used as VPN anonymizer, open proxies, web proxies and Tor exits. The database includes records for all public IPv4 addresses. |
| 7 | + |
| 8 | + |
| 9 | +Compilation |
| 10 | +=========== |
| 11 | +```bash |
| 12 | +javac com/ip2proxy/*.java |
| 13 | +jar cf ip2proxy.jar com/ip2proxy/*.class |
| 14 | +``` |
| 15 | + |
| 16 | +Sample Code |
| 17 | +=========== |
| 18 | +```java |
| 19 | +import com.ip2proxy.*; |
| 20 | + |
| 21 | +public class Main { |
| 22 | + public Main() { |
| 23 | + } |
| 24 | + |
| 25 | + public static void main(String[] args) { |
| 26 | + try { |
| 27 | + IP2Proxy Proxy = new IP2Proxy(); |
| 28 | + ProxyResult All; |
| 29 | + |
| 30 | + int IsProxy; |
| 31 | + String ProxyType; |
| 32 | + String CountryShort; |
| 33 | + String CountryLong; |
| 34 | + String Region; |
| 35 | + String City; |
| 36 | + String ISP; |
| 37 | + |
| 38 | + String IP = "221.121.146.0"; |
| 39 | + |
| 40 | + if (Proxy.Open("/usr/data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.BIN", IP2Proxy.IOModes.IP2PROXY_MEMORY_MAPPED) == 0) { |
| 41 | + System.out.println("GetModuleVersion: " + Proxy.GetModuleVersion()); |
| 42 | + System.out.println("GetPackageVersion: " + Proxy.GetPackageVersion()); |
| 43 | + System.out.println("GetDatabaseVersion: " + Proxy.GetDatabaseVersion()); |
| 44 | + |
| 45 | + // reading all available fields |
| 46 | + All = Proxy.GetAll(IP); |
| 47 | + System.out.println("Is_Proxy: " + String.valueOf(All.Is_Proxy)); |
| 48 | + System.out.println("Proxy_Type: " + All.Proxy_Type); |
| 49 | + System.out.println("Country_Short: " + All.Country_Short); |
| 50 | + System.out.println("Country_Long: " + All.Country_Long); |
| 51 | + System.out.println("Region: " + All.Region); |
| 52 | + System.out.println("City: " + All.City); |
| 53 | + System.out.println("ISP: " + All.ISP); |
| 54 | + |
| 55 | + // reading individual fields |
| 56 | + IsProxy = Proxy.IsProxy(IP); |
| 57 | + System.out.println("Is_Proxy: " + String.valueOf(IsProxy)); |
| 58 | + |
| 59 | + ProxyType = Proxy.GetProxyType(IP); |
| 60 | + System.out.println("Proxy_Type: " + ProxyType); |
| 61 | + |
| 62 | + CountryShort = Proxy.GetCountryShort(IP); |
| 63 | + System.out.println("Country_Short: " + CountryShort); |
| 64 | + |
| 65 | + CountryLong = Proxy.GetCountryLong(IP); |
| 66 | + System.out.println("Country_Long: " + CountryLong); |
| 67 | + |
| 68 | + Region = Proxy.GetRegion(IP); |
| 69 | + System.out.println("Region: " + Region); |
| 70 | + |
| 71 | + City = Proxy.GetCity(IP); |
| 72 | + System.out.println("City: " + City); |
| 73 | + |
| 74 | + ISP = Proxy.GetISP(IP); |
| 75 | + System.out.println("ISP: " + ISP); |
| 76 | + } |
| 77 | + else { |
| 78 | + System.out.println("Error reading BIN file."); |
| 79 | + } |
| 80 | + Proxy.Close(); |
| 81 | + } |
| 82 | + catch(Exception Ex) { |
| 83 | + System.out.println(Ex); |
| 84 | + } |
| 85 | + } |
| 86 | +} |
| 87 | +``` |
| 88 | + |
0 commit comments