ip2proxy

package module
v2.2.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2019 License: MIT Imports: 8 Imported by: 4

README

Go Report Card

IP2Proxy Go Package

This package 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 and search engine robots (SES). It lookup the proxy IP address from IP2Proxy BIN Data file. This data file can be downloaded at

Installation

To install this module type the following:


go get github.com/ip2location/ip2proxy-go

Methods

Below are the methods supported in this package.

Method Name Description
Open Open the IP2Proxy BIN data for lookup.
Close Close and clean up the file pointer.
PackageVersion Get the package version (1 to 8 for PX1 to PX8 respectively).
ModuleVersion Get the module version.
DatabaseVersion Get the database version.
IsProxy Check 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
GetAll Return the proxy information in an array.
GetProxyType Return the proxy type. Please visit IP2Location for the list of proxy types supported.
GetCountryShort Return the ISO3166-1 country code (2-digits) of the proxy.
GetCountryLong Return the ISO3166-1 country name of the proxy.
GetRegion Return the ISO3166-2 region name of the proxy. Please visit ISO3166-2 Subdivision Code for the information of ISO3166-2 supported.
GetCity Return the city name of the proxy.
GetIsp Return the ISP name of the proxy.
GetDomain Return the domain name of the proxy.
GetUsageType Return the usage type classification of the proxy. Please visit IP2Location for the list of usage types supported.
GetAsn Return the autonomous system number of the proxy.
GetAs Return the autonomous system name of the proxy.
GetLastSeen Return the number of days that the proxy was last seen.

Usage

package main

import (
	"fmt"
	"github.com/ip2location/ip2proxy-go"
)

func main() {
	if ip2proxy.Open("./IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN.BIN") == 0 {
		ip := "199.83.103.79"
		
		fmt.Printf("ModuleVersion: %s\n", ip2proxy.ModuleVersion())
		fmt.Printf("PackageVersion: %s\n", ip2proxy.PackageVersion())
		fmt.Printf("DatabaseVersion: %s\n", ip2proxy.DatabaseVersion())
		
		// functions for individual fields
		fmt.Printf("IsProxy: %d\n", ip2proxy.IsProxy(ip))
		fmt.Printf("ProxyType: %s\n", ip2proxy.GetProxyType(ip))
		fmt.Printf("CountryShort: %s\n", ip2proxy.GetCountryShort(ip))
		fmt.Printf("CountryLong: %s\n", ip2proxy.GetCountryLong(ip))
		fmt.Printf("Region: %s\n", ip2proxy.GetRegion(ip))
		fmt.Printf("City: %s\n", ip2proxy.GetCity(ip))
		fmt.Printf("ISP: %s\n", ip2proxy.GetIsp(ip))
		fmt.Printf("Domain: %s\n", ip2proxy.GetDomain(ip))
		fmt.Printf("UsageType: %s\n", ip2proxy.GetUsageType(ip))
		fmt.Printf("ASN: %s\n", ip2proxy.GetAsn(ip))
		fmt.Printf("AS: %s\n", ip2proxy.GetAs(ip))
		fmt.Printf("LastSeen: %s\n", ip2proxy.GetLastSeen(ip))
		
		// function for all fields
		all := ip2proxy.GetAll(ip)
		fmt.Printf("isProxy: %s\n", all["isProxy"])
		fmt.Printf("ProxyType: %s\n", all["ProxyType"])
		fmt.Printf("CountryShort: %s\n", all["CountryShort"])
		fmt.Printf("CountryLong: %s\n", all["CountryLong"])
		fmt.Printf("Region: %s\n", all["Region"])
		fmt.Printf("City: %s\n", all["City"])
		fmt.Printf("ISP: %s\n", all["ISP"])
		fmt.Printf("Domain: %s\n", all["Domain"])
		fmt.Printf("UsageType: %s\n", all["UsageType"])
		fmt.Printf("ASN: %s\n", all["ASN"])
		fmt.Printf("AS: %s\n", all["AS"])
		fmt.Printf("LastSeen: %s\n", all["LastSeen"])
	} else {
		fmt.Printf("Error reading BIN file.\n")
	}
	ip2proxy.Close()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() int8

close database file handle & reset

func DatabaseVersion

func DatabaseVersion() string

get database version

func GetAll

func GetAll(ipaddress string) map[string]string

get all fields

func GetAs

func GetAs(ipaddress string) string

get as

func GetAsn

func GetAsn(ipaddress string) string

get asn

func GetCity

func GetCity(ipaddress string) string

get city

func GetCountryLong

func GetCountryLong(ipaddress string) string

get country name

func GetCountryShort

func GetCountryShort(ipaddress string) string

get country code

func GetDomain

func GetDomain(ipaddress string) string

get domain

func GetIsp

func GetIsp(ipaddress string) string

get isp

func GetLastSeen

func GetLastSeen(ipaddress string) string

get last seen

func GetProxyType

func GetProxyType(ipaddress string) string

get proxy type

func GetRegion

func GetRegion(ipaddress string) string

get region

func GetUsageType

func GetUsageType(ipaddress string) string

get usage type

func IsProxy

func IsProxy(ipaddress string) int8

is proxy

func ModuleVersion

func ModuleVersion() string

get module version

func Open

func Open(dbpath string) int8

initialize the component with the database path

func PackageVersion

func PackageVersion() string

get package version

func Printrecord

func Printrecord(x IP2Proxyrecord)

for debugging purposes

Types

type IP2Proxyrecord

type IP2Proxyrecord struct {
	Country_short string
	Country_long  string
	Region        string
	City          string
	Isp           string
	Proxy_type    string
	Domain        string
	Usage_type    string
	Asn           string
	As            string
	Last_seen     string
	Is_proxy      int8
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL