@@ -16,13 +16,16 @@ This library requires IP2Proxy BIN database to function. You may download the BI
1616
1717## Sample Codes
1818
19- ### Query geolocation information from BIN database
19+ ### Query proxy information from BIN database
2020
21- You can query the geolocation information from the IP2Proxy BIN database as below:
21+ You can query the proxy information from the IP2Proxy BIN database as below:
2222
2323``` vb.net
24- Dim proxy As New IP2Proxy.Component
25- Dim all As IP2Proxy.ProxyResult
24+ Imports System.IO
25+ Imports IP2Proxy
26+
27+ Dim proxy As New Component
28+ Dim all As ProxyResult
2629
2730Dim isproxy As Integer
2831Dim proxytype As String
@@ -41,8 +44,8 @@ Dim provider As String
4144
4245Dim ip As String = "221.121.146.0"
4346
44- If proxy.Open( "C:\data\IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER.BIN" , IP2Proxy. Component.IOModes.IP2PROXY_MEMORY_MAPPED) = 0 Then
45- Console.WriteLine( "GetModuleVersion: " & proxy .GetModuleVersion())
47+ If proxy.Open( "C:\data\IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER.BIN" , Component.IOModes.IP2PROXY_MEMORY_MAPPED) = 0 Then
48+ Console.WriteLine( "GetModuleVersion: " & Component .GetModuleVersion())
4649 Console.WriteLine( "GetPackageVersion: " & proxy.GetPackageVersion())
4750 Console.WriteLine( "GetDatabaseVersion: " & proxy.GetDatabaseVersion())
4851
@@ -109,4 +112,104 @@ Else
109112 Console.WriteLine( "Error reading BIN file." )
110113End If
111114proxy.Close()
115+ ```
116+
117+ ### Query proxy information using a stream and async IP query
118+
119+ You can query the proxy information using a stream and async IP query as below:
120+
121+ ``` vb.net
122+ Imports System.IO
123+ Imports IP2Proxy
124+
125+ Dim proxy As New Component
126+ Dim all As ProxyResult
127+
128+ Dim isproxy As Integer
129+ Dim proxytype As String
130+ Dim countryshort As String
131+ Dim countrylong As String
132+ Dim region As String
133+ Dim city As String
134+ Dim isp As String
135+ Dim domain As String
136+ Dim usagetype As String
137+ Dim asn As String
138+ Dim [as] As String
139+ Dim lastseen As String
140+ Dim threat As String
141+ Dim provider As String
142+
143+ Dim ip As String = "221.121.146.0"
144+
145+ Using myStream = New FileStream( "C:\data\IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER.BIN" , FileMode.Open, FileAccess.Read, FileShare.Read)
146+ If proxy.Open(myStream) = 0 Then
147+ Console.WriteLine( "GetModuleVersion: " & Component.GetModuleVersion())
148+ Console.WriteLine( "GetPackageVersion: " & proxy.GetPackageVersion())
149+ Console.WriteLine( "GetDatabaseVersion: " & proxy.GetDatabaseVersion())
150+
151+ ' reading all available fields
152+ all = proxy.GetAllAsync(ip)
153+ Console.WriteLine( "Is_Proxy: " & all.Is_Proxy.ToString())
154+ Console.WriteLine( "Proxy_Type: " & all.Proxy_Type)
155+ Console.WriteLine( "Country_Short: " & all.Country_Short)
156+ Console.WriteLine( "Country_Long: " & all.Country_Long)
157+ Console.WriteLine( "Region: " & all.Region)
158+ Console.WriteLine( "City: " & all.City)
159+ Console.WriteLine( "ISP: " & all.ISP)
160+ Console.WriteLine( "Domain: " & all.Domain)
161+ Console.WriteLine( "Usage_Type: " & all.Usage_Type)
162+ Console.WriteLine( "ASN: " & all.ASN)
163+ Console.WriteLine( "AS: " & all.AS)
164+ Console.WriteLine( "Last_Seen: " & all.Last_Seen)
165+ Console.WriteLine( "Threat: " & all.Threat)
166+ Console.WriteLine( "Provider: " & all.Provider)
167+
168+ ' reading individual fields
169+ isproxy = proxy.IsProxyAsync(ip)
170+ Console.WriteLine( "Is_Proxy: " & isproxy.ToString())
171+
172+ proxytype = proxy.GetProxyTypeAsync(ip)
173+ Console.WriteLine( "Proxy_Type: " & proxytype)
174+
175+ countryshort = proxy.GetCountryShortAsync(ip)
176+ Console.WriteLine( "Country_Short: " & countryshort)
177+
178+ countrylong = proxy.GetCountryLongAsync(ip)
179+ Console.WriteLine( "Country_Long: " & countrylong)
180+
181+ region = proxy.GetRegionAsync(ip)
182+ Console.WriteLine( "Region: " & region)
183+
184+ city = proxy.GetCityAsync(ip)
185+ Console.WriteLine( "City: " & city)
186+
187+ isp = proxy.GetISPAsync(ip)
188+ Console.WriteLine( "ISP: " & isp)
189+
190+ domain = proxy.GetDomainAsync(ip)
191+ Console.WriteLine( "Domain: " & domain)
192+
193+ usagetype = proxy.GetUsageTypeAsync(ip)
194+ Console.WriteLine( "Usage_Type: " & usagetype)
195+
196+ asn = proxy.GetASNAsync(ip)
197+ Console.WriteLine( "ASN: " & asn)
198+
199+ [as] = proxy.GetASAsync(ip)
200+ Console.WriteLine( "AS: " & [as])
201+
202+ lastseen = proxy.GetLastSeenAsync(ip)
203+ Console.WriteLine( "Last_Seen: " & lastseen)
204+
205+ threat = proxy.GetThreatAsync(ip)
206+ Console.WriteLine( "Threat: " & threat)
207+
208+ provider = proxy.GetProviderAsync(ip)
209+ Console.WriteLine( "Provider: " & provider)
210+ Else
211+ Console.WriteLine( "Error reading BIN file." )
212+ End If
213+ proxy.Close()
214+ End Using
112215```
0 commit comments