ip2proxy-nodejs
Advanced tools
+1
-1
| { | ||
| "name": "ip2proxy-nodejs", | ||
| "version": "4.3.2", | ||
| "version": "4.4.0", | ||
| "description": "IP2Proxy proxy detection component", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
+5
-184
@@ -6,3 +6,3 @@ [](http://npm.im/ip2proxy-nodejs) | ||
| This module allows user to query an IP address if it was being used as VPN anonymizer, open proxies, web proxies, Tor exits, data center, web hosting (DCH) range, search engine robots (SES) and residential (RES). It lookup the proxy IP address from **IP2Proxy BIN Data** file. This data file can be downloaded at | ||
| This module allows user to query an IP address if it was being used as VPN anonymizer, open proxies, web proxies, Tor exits, data center, web hosting (DCH) range, search engine robots (SES), residential proxies (RES), consumer privacy networks (CPN), enterprise private networks (EPN) and fraud score. It lookup the proxy IP address from **IP2Proxy BIN Data** file. This data file can be downloaded at | ||
@@ -12,187 +12,6 @@ * Free IP2Proxy BIN Data: https://lite.ip2location.com | ||
| As an alternative, this module 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: | ||
| # Developer Documentation | ||
| To learn more about installation, usage, and code examples, please visit the developer documentation at [https://ip2proxy-nodejs.readthedocs.io/en/latest/index.html.](https://ip2proxy-nodejs.readthedocs.io/en/latest/index.html) | ||
| https://www.ip2location.com/web-service/ip2proxy | ||
| ## Installation | ||
| To install this module type the following: | ||
| ```bash | ||
| npm install ip2proxy-nodejs | ||
| ``` | ||
| ## QUERY USING THE BIN FILE | ||
| ## Methods | ||
| Below are the methods supported in this class. | ||
| |Method Name|Description| | ||
| |---|---| | ||
| |open|Open the IP2Proxy BIN data for lookup.| | ||
| |openAsync|Open the IP2Proxy BIN data for lookup asynchronously.| | ||
| |close|Close and clean up the file pointer.| | ||
| |getPackageVersion|Get the package version (1 to 11 for PX1 to PX11 respectively).| | ||
| |getModuleVersion|Get the module version.| | ||
| |getDatabaseVersion|Get the database version.| | ||
| |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>| | ||
| |isProxyAsync|Check whether if an IP address was a proxy asynchronously. 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>| | ||
| |getAll|Return the proxy information in an object.| | ||
| |getAllAsync|Return the proxy information in an object asynchronously.| | ||
| |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| | ||
| |getProxyTypeAsync|Return the proxy type asynchronously. 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| | ||
| |getCountryShort|Return the ISO3166-1 country code (2-digits) of the proxy.| | ||
| |getCountryShortAsync|Return the ISO3166-1 country code (2-digits) of the proxy asynchronously.| | ||
| |getCountryLong|Return the ISO3166-1 country name of the proxy.| | ||
| |getCountryLongAsync|Return the ISO3166-1 country name of the proxy asynchronously.| | ||
| |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| | ||
| |getRegionAsync|Return the ISO3166-2 region name of the proxy asynchronously. 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| | ||
| |getCity|Return the city name of the proxy.| | ||
| |getCityAsync|Return the city name of the proxy asynchronously.| | ||
| |getISP|Return the ISP name of the proxy.| | ||
| |getISPAsync|Return the ISP name of the proxy asynchronously.| | ||
| |getDomain|Return the domain name of the proxy.| | ||
| |getDomainAsync|Return the domain name of the proxy asynchronously.| | ||
| |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.| | ||
| |getUsageTypeAsync|Return the usage type classification of the proxy asynchronously. 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.| | ||
| |getASN|Return the autonomous system number of the proxy.| | ||
| |getASNAsync|Return the autonomous system number of the proxy asynchronously.| | ||
| |getAS|Return the autonomous system name of the proxy.| | ||
| |getASAsync|Return the autonomous system name of the proxy asynchronously.| | ||
| |getLastSeen|Return the number of days that the proxy was last seen.| | ||
| |getLastSeenAsync|Return the number of days that the proxy was last seen asynchronously.| | ||
| |getThreat|Return the threat type of the proxy.| | ||
| |getThreatAsync|Return the threat type of the proxy asynchronously.| | ||
| |getProvider|Return the provider of the proxy.| | ||
| |getProviderAsync|Return the provider of the proxy asynchronously.| | ||
| ## Usage | ||
| ```javascript | ||
| const {IP2Proxy} = require("ip2proxy-nodejs"); | ||
| let ip2proxy = new IP2Proxy(); | ||
| if (ip2proxy.open("./IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER.BIN") == 0) { | ||
| ip = '199.83.103.79'; | ||
| console.log("GetModuleVersion: " + ip2proxy.getModuleVersion()); | ||
| console.log("GetPackageVersion: " + ip2proxy.getPackageVersion()); | ||
| console.log("GetDatabaseVersion: " + ip2proxy.getDatabaseVersion()); | ||
| // functions for individual fields | ||
| console.log("isProxy: " + ip2proxy.isProxy(ip)); | ||
| console.log("ProxyType: " + ip2proxy.getProxyType(ip)); | ||
| console.log("CountryShort: " + ip2proxy.getCountryShort(ip)); | ||
| console.log("CountryLong: " + ip2proxy.getCountryLong(ip)); | ||
| console.log("Region: " + ip2proxy.getRegion(ip)); | ||
| console.log("City: " + ip2proxy.getCity(ip)); | ||
| console.log("ISP: " + ip2proxy.getISP(ip)); | ||
| console.log("Domain: " + ip2proxy.getDomain(ip)); | ||
| console.log("UsageType: " + ip2proxy.getUsageType(ip)); | ||
| console.log("ASN: " + ip2proxy.getASN(ip)); | ||
| console.log("AS: " + ip2proxy.getAS(ip)); | ||
| console.log("LastSeen: " + ip2proxy.getLastSeen(ip)); | ||
| console.log("Threat: " + ip2proxy.getThreat(ip)); | ||
| console.log("Provider: " + ip2proxy.getProvider(ip)); | ||
| // function for all fields | ||
| let all = ip2proxy.getAll(ip); | ||
| console.log("isProxy: " + all.isProxy); | ||
| console.log("proxyType: " + all.proxyType); | ||
| console.log("countryShort: " + all.countryShort); | ||
| console.log("countryLong: " + all.countryLong); | ||
| console.log("region: " + all.region); | ||
| console.log("city: " + all.city); | ||
| console.log("isp: " + all.isp); | ||
| console.log("domain: " + all.domain); | ||
| console.log("usagetype: " + all.usageType); | ||
| console.log("asn: " + all.asn); | ||
| console.log("as: " + all.as); | ||
| console.log("lastSeen: " + all.lastSeen); | ||
| console.log("threat: " + all.threat); | ||
| console.log("provider: " + all.provider); | ||
| } | ||
| else { | ||
| console.log("Error reading BIN file."); | ||
| } | ||
| ip2proxy.close(); | ||
| ``` | ||
| ## Asynchronous Usage | ||
| ```javascript | ||
| const {IP2Proxy} = require("ip2proxy-nodejs"); | ||
| let ip2proxy = new IP2Proxy(); | ||
| ip2proxy.openAsync("./IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER.BIN").then((status) => { | ||
| if (status == 0) { | ||
| ip = '199.83.103.79'; | ||
| ip2proxy.getAllAsync(ip).then(all => { | ||
| console.log("isProxy: " + all.isProxy); | ||
| console.log("proxyType: " + all.proxyType); | ||
| console.log("countryShort: " + all.countryShort); | ||
| console.log("countryLong: " + all.countryLong); | ||
| console.log("region: " + all.region); | ||
| console.log("city: " + all.city); | ||
| console.log("isp: " + all.isp); | ||
| console.log("domain: " + all.domain); | ||
| console.log("usagetype: " + all.usageType); | ||
| console.log("asn: " + all.asn); | ||
| console.log("as: " + all.as); | ||
| console.log("lastSeen: " + all.lastSeen); | ||
| console.log("threat: " + all.threat); | ||
| console.log("provider: " + all.provider); | ||
| }); | ||
| } | ||
| else { | ||
| console.log("Error reading BIN."); | ||
| } | ||
| }); | ||
| ``` | ||
| ## QUERY USING THE IP2PROXY PROXY DETECTION WEB SERVICE | ||
| ## Methods | ||
| Below are the methods supported in this class. | ||
| |Method Name|Description| | ||
| |---|---| | ||
| |open(apiKey, apiPackage, useSSL = true)| Expects 2 or 3 input parameters:<ol><li>IP2Proxy API Key.</li><li>Package (PX1 - PX11)</li></li><li>Use HTTPS or HTTP</li></ol> | | ||
| |lookup(myIP, callback)|Query IP address. This method returns an object 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>| | ||
| |getCredit(callback)|This method returns the web service credit balance in an object.| | ||
| ## Usage | ||
| ```javascript | ||
| const {IP2ProxyWebService} = require("ip2proxy-nodejs"); | ||
| let ws = new IP2ProxyWebService(); | ||
| let ip = "8.8.8.8"; | ||
| let apiKey = "YOUR_API_KEY"; | ||
| let apiPackage = "PX11"; | ||
| let useSSL = true; | ||
| ws.open(apiKey, apiPackage, useSSL); | ||
| ws.lookup(ip, (err, data) => { | ||
| if (!err) { | ||
| console.log(data); | ||
| ws.getCredit((err, data) => { | ||
| if (!err) { | ||
| console.log(data); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
| ``` | ||
| ### Proxy Type | ||
@@ -209,2 +28,4 @@ | ||
| |RES|Residential Proxies [PX10+]| | ||
| |CPN|Consumer Privacy Networks. [PX11+]| | ||
| |EPN|Enterprise Private Networks. [PX11+]| | ||
@@ -211,0 +32,0 @@ ### Usage Type |
+18
-0
@@ -179,2 +179,3 @@ export class IP2Proxy { | ||
| provider: string; | ||
| fraudScore: string; | ||
| }; | ||
@@ -205,2 +206,3 @@ /** | ||
| provider: string; | ||
| fraudScore: string; | ||
| }>; | ||
@@ -422,2 +424,16 @@ /** | ||
| /** | ||
| * Returns the fraud score. | ||
| * | ||
| * @param myIP The IP address to query. | ||
| * @returns The fraud score. | ||
| */ | ||
| getFraudScore(myIP: string): string; | ||
| /** | ||
| * Returns the fraud score asynchronously. | ||
| * | ||
| * @param myIP The IP address to query. | ||
| * @returns The promise of the fraud score. | ||
| */ | ||
| getFraudScoreAsync(myIP: string): Promise<string>; | ||
| /** | ||
| * Returns all fields. | ||
@@ -445,2 +461,3 @@ * | ||
| provider: string; | ||
| fraudScore: string; | ||
| }; | ||
@@ -470,2 +487,3 @@ /** | ||
| provider: string; | ||
| fraudScore: string; | ||
| }>; | ||
@@ -472,0 +490,0 @@ #private; |
+55
-13
@@ -7,16 +7,17 @@ const net = require("net"); | ||
| // For BIN queries | ||
| const VERSION = "4.3.2"; | ||
| const VERSION = "4.4.0"; | ||
| const MAX_INDEX = 65536; | ||
| const COUNTRY_POSITION = [0, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]; | ||
| const REGION_POSITION = [0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4]; | ||
| const CITY_POSITION = [0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5]; | ||
| const ISP_POSITION = [0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6]; | ||
| const PROXY_TYPE_POSITION = [0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]; | ||
| const DOMAIN_POSITION = [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7]; | ||
| const USAGE_TYPE_POSITION = [0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8]; | ||
| const ASN_POSITION = [0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9]; | ||
| const AS_POSITION = [0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10]; | ||
| const LAST_SEEN_POSITION = [0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11]; | ||
| const THREAT_POSITION = [0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12]; | ||
| const PROVIDER_POSITION = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13]; | ||
| const COUNTRY_POSITION = [0, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]; | ||
| const REGION_POSITION = [0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]; | ||
| const CITY_POSITION = [0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]; | ||
| const ISP_POSITION = [0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6]; | ||
| const PROXY_TYPE_POSITION = [0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]; | ||
| const DOMAIN_POSITION = [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7]; | ||
| const USAGE_TYPE_POSITION = [0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8]; | ||
| const ASN_POSITION = [0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9]; | ||
| const AS_POSITION = [0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10]; | ||
| const LAST_SEEN_POSITION = [0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11]; | ||
| const THREAT_POSITION = [0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 12]; | ||
| const PROVIDER_POSITION = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 13]; | ||
| const FRAUD_SCORE_POSITION = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14]; | ||
| const MAX_IPV4_RANGE = BigInt(4294967295); | ||
@@ -46,2 +47,3 @@ const MAX_IPV6_RANGE = BigInt("340282366920938463463374607431768211455"); | ||
| PROVIDER: 14, | ||
| FRAUD_SCORE: 15, | ||
| ALL: 100, | ||
@@ -101,2 +103,3 @@ }; | ||
| #providerPositionOffset = 0; | ||
| #fraudScorePositionOffset = 0; | ||
@@ -115,2 +118,3 @@ #countryEnabled = 0; | ||
| #providerEnabled = 0; | ||
| #fraudScoreEnabled = 0; | ||
@@ -351,2 +355,6 @@ #myDB = { | ||
| PROVIDER_POSITION[dbt] != 0 ? (PROVIDER_POSITION[dbt] - 2) << 2 : 0; | ||
| this.#fraudScorePositionOffset = | ||
| FRAUD_SCORE_POSITION[dbt] != 0 | ||
| ? (FRAUD_SCORE_POSITION[dbt] - 2) << 2 | ||
| : 0; | ||
@@ -365,2 +373,3 @@ this.#countryEnabled = COUNTRY_POSITION[dbt] != 0 ? 1 : 0; | ||
| this.#providerEnabled = PROVIDER_POSITION[dbt] != 0 ? 1 : 0; | ||
| this.#fraudScoreEnabled = FRAUD_SCORE_POSITION[dbt] != 0 ? 1 : 0; | ||
@@ -480,2 +489,6 @@ if (this.#myDB.indexed == 1) { | ||
| PROVIDER_POSITION[dbt] != 0 ? (PROVIDER_POSITION[dbt] - 2) << 2 : 0; | ||
| this.#fraudScorePositionOffset = | ||
| FRAUD_SCORE_POSITION[dbt] != 0 | ||
| ? (FRAUD_SCORE_POSITION[dbt] - 2) << 2 | ||
| : 0; | ||
@@ -494,2 +507,3 @@ this.#countryEnabled = COUNTRY_POSITION[dbt] != 0 ? 1 : 0; | ||
| this.#providerEnabled = PROVIDER_POSITION[dbt] != 0 ? 1 : 0; | ||
| this.#fraudScoreEnabled = FRAUD_SCORE_POSITION[dbt] != 0 ? 1 : 0; | ||
@@ -820,2 +834,9 @@ if (this.#myDB.indexed == 1) { | ||
| } | ||
| if (this.#fraudScoreEnabled) { | ||
| if (mode == MODES.ALL || mode == MODES.FRAUD_SCORE) { | ||
| data.fraudScore = this.readStr( | ||
| this.read32Row(this.#fraudScorePositionOffset, row) | ||
| ); | ||
| } | ||
| } | ||
@@ -1050,2 +1071,9 @@ if (data.countryShort == "-" || data.proxyType == "-") { | ||
| } | ||
| if (this.#fraudScoreEnabled) { | ||
| if (mode == MODES.ALL || mode == MODES.FRAUD_SCORE) { | ||
| data.fraudScore = await this.readStrAsync( | ||
| this.read32Row(this.#fraudScorePositionOffset, row) | ||
| ); | ||
| } | ||
| } | ||
@@ -1092,2 +1120,3 @@ if (data.countryShort == "-" || data.proxyType == "-") { | ||
| provider: "?", | ||
| fraudScore: "?", | ||
| }; | ||
@@ -1141,2 +1170,3 @@ | ||
| provider: "?", | ||
| fraudScore: "?", | ||
| }; | ||
@@ -1369,2 +1399,14 @@ | ||
| // Return a string for the fraud score | ||
| getFraudScore(myIP) { | ||
| let data = this.proxyQuery(myIP, MODES.FRAUD_SCORE); | ||
| return data.fraudScore; | ||
| } | ||
| // Return a string for the fraud score async | ||
| async getFraudScoreAsync(myIP) { | ||
| let data = await this.proxyQueryAsync(myIP, MODES.FRAUD_SCORE); | ||
| return data.fraudScore; | ||
| } | ||
| // Return all results | ||
@@ -1371,0 +1413,0 @@ getAll(myIP) { |
+2
-2
@@ -6,3 +6,3 @@ const {IP2Proxy, IP2ProxyWebService} = require("ip2proxy-nodejs"); | ||
| ip2proxy.open('PX11.BIN'); | ||
| ip2proxy.open('PX12.BIN'); | ||
@@ -29,3 +29,3 @@ console.log("Module version " + ip2proxy.getModuleVersion()); | ||
| let apiKey = "YOUR_API_KEY"; | ||
| let apiPackage = "PX11"; | ||
| let apiPackage = "PX12"; | ||
| let useSSL = true; | ||
@@ -32,0 +32,0 @@ |
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
1942
3.08%66368
-8.45%52
-77.49%