11export class IP2Proxy {
2- readRow ( readBytes : any , position : any ) : any ;
3- readBin ( readBytes : any , position : any , readType : any , isBigInt : any ) : any ;
4- read8 ( position : any ) : any ;
5- read8Row ( position : any , buffer : any ) : any ;
6- read32 ( position : any , isBigInt : any ) : any ;
7- read32Row ( position : any , buffer : any ) : any ;
8- read128Row ( position : any , buffer : any ) : any ;
9- read32Or128Row ( position : any , buffer : any , len : any ) : any ;
10- read32Or128 ( position : any , ipType : any ) : any ;
11- read128 ( position : any ) : any ;
12- readStr ( position : any ) : any ;
2+ /**
3+ * Reads bytes from file into buffer.
4+ *
5+ * @param readBytes The number of bytes to read.
6+ * @param position The file offset to start reading.
7+ * @returns buffer containing the read bytes.
8+ */
9+ readRow ( readBytes : number , position : number ) : any ;
10+ /**
11+ * Reads bytes from file and convert to specified data type.
12+ *
13+ * @param readBytes The number of bytes to read.
14+ * @param position The file offset to start reading.
15+ * @param readType The data type to convert the bytes to. (Valid values: int8|int32|uint32|float|str|int128)
16+ * @param isBigInt Whether to convert to BigInteger object.
17+ * @returns The value of the specified data type.
18+ */
19+ readBin ( readBytes : number , position : number , readType : string , isBigInt : boolean ) : any ;
20+ /**
21+ * Reads unsigned 8-bit integer from file.
22+ *
23+ * @param position The file offset to start reading.
24+ * @returns Unsigned 8-bit integer.
25+ */
26+ read8 ( position : number ) : number ;
27+ /**
28+ * Reads unsigned 8-bit integer from buffer.
29+ *
30+ * @param position The buffer offset to start reading.
31+ * @param buffer The buffer containing the data.
32+ * @returns Unsigned 8-bit integer.
33+ */
34+ read8Row ( position : number , buffer : any ) : number ;
35+ /**
36+ * Reads unsigned 32-bit integer from file.
37+ *
38+ * @param position The file offset to start reading.
39+ * @param isBigInt Whether to convert to BigInteger object.
40+ * @returns Unsigned 32-bit integer.
41+ */
42+ read32 ( position : number , isBigInt : boolean ) : number ;
43+ /**
44+ * Reads unsigned 32-bit integer from buffer.
45+ *
46+ * @param position The buffer offset to start reading.
47+ * @param buffer The buffer containing the data.
48+ * @returns Unsigned 32-bit integer.
49+ */
50+ read32Row ( position : number , buffer : any ) : number ;
51+ /**
52+ * Reads unsigned 128-bit integer from buffer.
53+ *
54+ * @param position The buffer offset to start reading.
55+ * @param buffer The buffer containing the data.
56+ * @returns BigInteger object.
57+ */
58+ read128Row ( position : number , buffer : any ) : any ;
59+ /**
60+ * Reads either unsigned 32-bit or 128-bit integer from buffer.
61+ *
62+ * @param position The buffer offset to start reading.
63+ * @param buffer The buffer containing the data.
64+ * @param len The number of bytes to read.
65+ * @returns BigInteger object or unsigned 32-bit integer.
66+ */
67+ read32Or128Row ( position : number , buffer : any , len : number ) : any ;
68+ /**
69+ * Reads either unsigned 32-bit or 128-bit integer from file.
70+ *
71+ * @param position The file offset to start reading.
72+ * @param ipType 4 for IPv4 or 6 for IPv6.
73+ * @returns BigInteger object or unsigned 32-bit integer.
74+ */
75+ read32Or128 ( position : number , ipType : number ) : any ;
76+ /**
77+ * Reads unsigned 128-bit integer from file.
78+ *
79+ * @param position The file offset to start reading.
80+ * @returns BigInteger object.
81+ */
82+ read128 ( position : number ) : any ;
83+ /**
84+ * Reads string from file.
85+ *
86+ * @param position The file offset to start reading.
87+ * @returns String.
88+ */
89+ readStr ( position : number ) : string ;
90+ /**
91+ * Reads BIN file metadata.
92+ *
93+ * @returns Whether metadata read successfully.
94+ */
1395 loadBin ( ) : boolean ;
14- open ( binPath : any ) : 0 | - 1 ;
96+ /**
97+ * Initializes with BIN file path and pre-loads metadata.
98+ *
99+ * @param binPath The path to the BIN file.
100+ * @returns 0 if successful else -1 for errors.
101+ */
102+ open ( binPath : string ) : 0 | - 1 ;
103+ /**
104+ * Resets metadata and closes file handle.
105+ *
106+ * @returns 0 if successful else -1 for errors.
107+ */
15108 close ( ) : 0 | - 1 ;
16- proxyQueryData ( myIP : any , ipType : any , data : any , mode : any ) : void ;
17- proxyQuery ( myIP : any , mode : any ) : {
109+ /**
110+ * Retrieves proxy data into supplied object.
111+ *
112+ * @param myIP The IP address to query.
113+ * @param ipType 4 for IPv4 or 6 for IPv6.
114+ * @param data The object to store the results.
115+ * @param mode The fields to read.
116+ */
117+ proxyQueryData ( myIP : string , ipType : number , data : any , mode : any ) : void ;
118+ /**
119+ * Performs validations and returns proxy data.
120+ *
121+ * @param myIP The IP address to query.
122+ * @param mode The fields to read.
123+ * @returns The proxy data.
124+ */
125+ proxyQuery ( myIP : string , mode : any ) : {
18126 ip : string ;
19127 ipNo : string ;
20128 isProxy : number ;
@@ -32,24 +140,129 @@ export class IP2Proxy {
32140 threat : string ;
33141 provider : string ;
34142 } ;
143+ /**
144+ * Returns the module version.
145+ *
146+ * @returns The module version.
147+ */
35148 getModuleVersion ( ) : string ;
149+ /**
150+ * Returns the database package.
151+ *
152+ * @returns The database package.
153+ */
36154 getPackageVersion ( ) : number ;
155+ /**
156+ * Returns the database version.
157+ *
158+ * @returns The database version.
159+ */
37160 getDatabaseVersion ( ) : string ;
38- isProxy ( myIP : any ) : number ;
39- getCountryShort ( myIP : any ) : string ;
40- getCountryLong ( myIP : any ) : string ;
41- getRegion ( myIP : any ) : string ;
42- getCity ( myIP : any ) : string ;
43- getISP ( myIP : any ) : string ;
44- getProxyType ( myIP : any ) : string ;
45- getDomain ( myIP : any ) : string ;
46- getUsageType ( myIP : any ) : string ;
47- getASN ( myIP : any ) : string ;
48- getAS ( myIP : any ) : string ;
49- getLastSeen ( myIP : any ) : string ;
50- getThreat ( myIP : any ) : string ;
51- getProvider ( myIP : any ) : string ;
52- getAll ( myIP : any ) : {
161+ /**
162+ * Whether IP is a proxy server.
163+ *
164+ * @param myIP The IP address to query.
165+ * @returns -1 if error, 0 if not a proxy, 1 if proxy except DCH and SES, 2 if proxy and DCH or SES
166+ */
167+ isProxy ( myIP : string ) : number ;
168+ /**
169+ * Returns the ISO 3166 country code.
170+ *
171+ * @param myIP The IP address to query.
172+ * @returns The country code.
173+ */
174+ getCountryShort ( myIP : string ) : string ;
175+ /**
176+ * Returns the country name.
177+ *
178+ * @param myIP The IP address to query.
179+ * @returns The country name.
180+ */
181+ getCountryLong ( myIP : string ) : string ;
182+ /**
183+ * Returns the region or state.
184+ *
185+ * @param myIP The IP address to query.
186+ * @returns The region or state.
187+ */
188+ getRegion ( myIP : string ) : string ;
189+ /**
190+ * Returns the city.
191+ *
192+ * @param myIP The IP address to query.
193+ * @returns The city.
194+ */
195+ getCity ( myIP : string ) : string ;
196+ /**
197+ * Returns the Internet Service Provider.
198+ *
199+ * @param myIP The IP address to query.
200+ * @returns The ISP.
201+ */
202+ getISP ( myIP : string ) : string ;
203+ /**
204+ * Returns the proxy type.
205+ *
206+ * @param myIP The IP address to query.
207+ * @returns The proxy type.
208+ */
209+ getProxyType ( myIP : string ) : string ;
210+ /**
211+ * Returns the domain name.
212+ *
213+ * @param myIP The IP address to query.
214+ * @returns The domain name.
215+ */
216+ getDomain ( myIP : string ) : string ;
217+ /**
218+ * Returns the usage type.
219+ *
220+ * @param myIP The IP address to query.
221+ * @returns The usage type.
222+ */
223+ getUsageType ( myIP : string ) : string ;
224+ /**
225+ * Returns the autonomous system number.
226+ *
227+ * @param myIP The IP address to query.
228+ * @returns The ASN.
229+ */
230+ getASN ( myIP : string ) : string ;
231+ /**
232+ * Returns the autonomous system name.
233+ *
234+ * @param myIP The IP address to query.
235+ * @returns The AS.
236+ */
237+ getAS ( myIP : string ) : string ;
238+ /**
239+ * Returns the number of days ago the proxy was last seen.
240+ *
241+ * @param myIP The IP address to query.
242+ * @returns The number of days ago the proxy was last seen.
243+ */
244+ getLastSeen ( myIP : string ) : string ;
245+ /**
246+ * Returns the security threat reported.
247+ *
248+ * @param myIP The IP address to query.
249+ * @returns SPAM if spammer, SCANNER if network scanner, BOTNET if malware infected device.
250+ */
251+ getThreat ( myIP : string ) : string ;
252+ /**
253+ * Returns the name of the VPN provider.
254+ *
255+ * @param myIP The IP address to query.
256+ * @returns The name of the VPN provider.
257+ */
258+ getProvider ( myIP : string ) : string ;
259+ /**
260+ * Returns all fields.
261+ *
262+ * @param myIP The IP address to query.
263+ * @returns All proxy fields.
264+ */
265+ getAll ( myIP : string ) : {
53266 ip : string ;
54267 ipNo : string ;
55268 isProxy : number ;
@@ -70,9 +283,31 @@ export class IP2Proxy {
70283 #private;
71284}
72285export class IP2ProxyWebService {
73- open ( apiKey : any , apiPackage : any , useSSL ?: boolean ) : void ;
286+ /**
287+ * Initializes with the IP2Proxy Web Service API key and the package to query.
288+ *
289+ * @param apiKey The IP2Proxy Web Service API key.
290+ * @param apiPackage The web service package to query.
291+ * @param useSSL Whether to use SSL to call the web service.
292+ */
293+ open ( apiKey : string , apiPackage : string , useSSL ?: boolean ) : void ;
294+ /**
295+ * Performs parameter validations.
296+ *
297+ */
74298 checkParams ( ) : void ;
75- lookup ( myIP : any , callback : any ) : void ;
299+ /**
300+ * Queries the IP2Proxy Web Service for proxy data on the IP address.
301+ *
302+ * @param myIP The IP address to query.
303+ * @param callback Callback function to receive the proxy data.
304+ */
305+ lookup ( myIP : string , callback : any ) : void ;
306+ /**
307+ * Queries the IP2Proxy Web Service for credit balance.
308+ *
309+ * @param callback Callback function to receive the credit balance.
310+ */
76311 getCredit ( callback : any ) : void ;
77312 #private;
78313}
0 commit comments