ip2proxy-d 1.0.0

IP2Proxy D Library


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

IP2Proxy D Library

This D library allows user to query an IP address if it was being used as open proxy, web proxy, VPN anonymizer and TOR exits. It lookup the proxy IP address from IP2Proxy BIN Data file. This data file can be downloaded at

  • Free IP2Proxy BIN Data: http://lite.ip2location.com
  • Commercial IP2Proxy BIN Data: http://www.ip2location.com/proxy-database

Installation

To install this library using dub:

"dependencies": {
    "ip2proxy-d": "~master"
}

Methods

Below are the methods supported in this library.

Method NameDescription
openOpen the IP2Proxy BIN data for lookup.
closeClose and reset metadata.
package_versionGet the package version (1 to 4 for PX1 to PX4 respectively).
module_versionGet the module version.
database_versionGet the database version.
is_proxyCheck 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</li></ul>
get_allReturn the proxy information in an array.
getproxytypeReturn the proxy type. Please visit <a href="https://www.ip2location.com/databases/px4-ip-proxytype-country-region-city-isp" target="_blank">IP2Location</a> 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.
get_regionReturn 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
get_cityReturn the city name of the proxy.
get_ispReturn the ISP name of the proxy.

Usage

import std.stdio;
import ip2proxy;

int main() {
	string db = "./IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.BIN";
	auto prox = new ip2proxy();
	
	if (prox.open(db) == 0) {
		auto ip = "199.83.103.79";
		
		writeln("ModuleVersion: ", prox.module_version());
		writeln("PackageVersion: ", prox.package_version());
		writeln("DatabaseVersion: ", prox.database_version());
		
		// functions for individual fields
		writeln("IsProxy: ", prox.is_proxy(ip));
		writeln("ProxyType: ", prox.get_proxy_type(ip));
		writeln("CountryShort: ", prox.get_country_short(ip));
		writeln("CountryLong: ", prox.get_country_long(ip));
		writeln("Region: ", prox.get_region(ip));
		writeln("City: ", prox.get_city(ip));
		writeln("ISP: ", prox.get_isp(ip));
		
		// function for all fields
		auto all = prox.get_all(ip);
		writeln("isProxy: ", all["isProxy"]);
		writeln("ProxyType: ", all["ProxyType"]);
		writeln("CountryShort: ", all["CountryShort"]);
		writeln("CountryLong: ", all["CountryLong"]);
		writeln("Region: ", all["Region"]);
		writeln("City: ", all["City"]);
		writeln("ISP: ", all["ISP"]);
	}
	else {
		writeln("Error reading BIN file.");
	}
	prox.close();
	
	return 0;
}
Authors:
  • IP2Location
Dependencies:
none
Versions:
1.0.0 2018-Jun-29
~master 2018-Jun-29
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 0 downloads total

Score:
0.6
Short URL:
ip2proxy-d.dub.pm