Get Started With IP2Proxy C Module

Dependencies

This library requires IP2Proxy BIN database to function. You may download the BIN database at

Note

An outdated BIN database was provided in the data folder for your testing. You are recommended to visit the above links to download the latest BIN database.


Installation

This library can be compiled and installed in different platform. Please refer to different section for the respective platform.

Unix/Linux

 autoreconf -i -v --force
 ./configure
 make

Debian

AMD64

curl -LO https://github.com/ip2location/ip2proxy-c/releases/download/4.2.0/ip2proxy-4.2.0-amd64.deb
sudo dpkg -i ip2proxy-4.2.0-amd64.deb

ARM64

curl -LO https://github.com/ip2location/ip2proxy-c/releases/download/4.2.0/ip2proxy-4.2.0-arm64.deb
sudo dpkg -i ip2proxy-4.2.0-arm64.deb

Ubuntu

sudo add-apt-repository ppa:ip2location/ip2proxy
sudo apt update
sudo apt install ip2proxy

Windows

 Execute "vcvarsall.bat". (This file is part of Microsoft Visual C, not ip2location code)
 nmake -f Makefile.win

MacOS

 autoreconf -i -v --force
 export CFLAGS=-I/usr/include/malloc
 ./configure
 make

Sample Codes

Query geolocation information from BIN database

You can query the geolocation information from the IP2Proxy BIN database as below:

#include "IP2Proxy.h"

IP2Proxy *IP2ProxyObj = IP2Proxy_open("../data/SAMPLE.BIN");
IP2ProxyRecord *record = IP2Proxy_get_all(IP2ProxyObj, "161.11.12.13");
printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
	record->country_short,
	record->country_long,
	record->region,
	record->city,
	record->isp,
	record->is_proxy;
	record->proxy_type,
	record->domain,
	record->usage_type,
	record->asn,
	record->as_,
	record->last_seen,
	record->threat,
	record->provider,
	record->fraud_score);
IP2Proxy_free_record(record);
IP2Proxy_close(IP2ProxyObj);

IP2Proxy Sample Database (BIN)

Sample Packages - BIN File IPv4 + IPv6
IP2Proxy PX1 Download (391.15 kB)
IP2Proxy PX2 Download (406.80 kB)
IP2Proxy PX3 Download (436.24 kB)
IP2Proxy PX4 Download (471.65 kB)
IP2Proxy PX5 Download (491.98 kB)
IP2Proxy PX6 Download (494.79 kB)
IP2Proxy PX7 Download (536.04 kB)
IP2Proxy PX8 Download (542.17 kB)
IP2Proxy PX9 Download (542.01 kB)
IP2Proxy PX10 Download (673.87 kB)
IP2Proxy PX11 Download (680.81 kB)
IP2Proxy PX12 Download (685.90 kB)