New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ip2proxy-nodejs

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip2proxy-nodejs

IP2Proxy proxy detection component

Source
npmnpm
Version
4.0.0
Version published
Maintainers
1
Created
Source

npm npm

IP2Proxy Node.js Module

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

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:

https://www.ip2location.com/web-service/ip2proxy

Installation

To install this module type the following:


npm install ip2proxy-nodejs

QUERY USING THE BIN FILE

Methods

Below are the methods supported in this class.

Method NameDescription
openOpen the IP2Proxy BIN data for lookup.
closeClose and clean up the file pointer.
getPackageVersionGet the package version (1 to 11 for PX1 to PX11 respectively).
getModuleVersionGet the module version.
getDatabaseVersionGet the database version.
isProxyCheck whether if an IP address was a proxy. Returned value:
  • -1 : errors
  • 0 : not a proxy
  • 1 : a proxy
  • 2 : a data center IP address or search engine robot
getAllReturn the proxy information in an object.
getProxyTypeReturn the proxy type. Please visit IP2Location for the list of proxy types supported
getCountryShortReturn the ISO3166-1 country code (2-digits) of the proxy.
getCountryLongReturn the ISO3166-1 country name of the proxy.
getRegionReturn the ISO3166-2 region name of the proxy. Please visit ISO3166-2 Subdivision Code for the information of ISO3166-2 supported
getCityReturn the city name of the proxy.
getISPReturn the ISP name of the proxy.
getDomainReturn the domain name of the proxy.
getUsageTypeReturn the usage type classification of the proxy. Please visit IP2Location for the list of usage types supported.
getASNReturn the autonomous system number of the proxy.
getASReturn the autonomous system name of the proxy.
getLastSeenReturn the number of days that the proxy was last seen.
getThreatReturn the threat type of the proxy.
getProviderReturn the provider of the proxy.

Usage

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();

QUERY USING THE IP2PROXY PROXY DETECTION WEB SERVICE

Methods

Below are the methods supported in this class.

Method NameDescription
open(apiKey, apiPackage, useSSL = true)Expects 2 or 3 input parameters:
  • IP2Proxy API Key.
  • Package (PX1 - PX11)
  • Use HTTPS or HTTP
lookup(myIP, callback)Query IP address. This method returns an object containing the proxy info.
  • countryCode
  • countryName
  • regionName
  • cityName
  • isp
  • domain
  • usageType
  • asn
  • as
  • lastSeen
  • threat
  • proxyType
  • isProxy
  • provider
    getCredit(callback)This method returns the web service credit balance in an object.

    Usage

    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

    Proxy TypeDescription
    VPNAnonymizing VPN services
    TORTor Exit Nodes
    PUBPublic Proxies
    WEBWeb Proxies
    DCHHosting Providers/Data Center
    SESSearch Engine Robots
    RESResidential Proxies [PX10+]

    Usage Type

    Usage TypeDescription
    COMCommercial
    ORGOrganization
    GOVGovernment
    MILMilitary
    EDUUniversity/College/School
    LIBLibrary
    CDNContent Delivery Network
    ISPFixed Line ISP
    MOBMobile ISP
    DCHData Center/Web Hosting/Transit
    SESSearch Engine Spider
    RSVReserved

    Threat Type

    Threat TypeDescription
    SPAMSpammer
    SCANNERSecurity Scanner or Attack
    BOTNETSpyware or Malware

    Keywords

    vpn-detection

    FAQs

    Package last updated on 15 Sep 2021

    Did you know?

    Socket

    Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

    Install

    Related posts