ip2proxy

package module
v2.3.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: MIT Imports: 8 Imported by: 0

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() {
	db, err := ip2proxy.OpenDB("./IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN.BIN")
	
	if err != nil {
		return
	}
	ip := "199.83.103.79"
	all, err := db.GetAll(ip)
	
	if err != nil {
		fmt.Print(err)
		return
	}
	
	fmt.Printf("ModuleVersion: %s\n", ip2proxy.ModuleVersion())
	fmt.Printf("PackageVersion: %s\n", db.PackageVersion())
	fmt.Printf("DatabaseVersion: %s\n", db.DatabaseVersion())
	
	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"])
	
	db.Close()
}

Documentation

Overview

This ip2proxy 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) by using the IP2Proxy database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close deprecated

func Close() int8

Close will close the file handle to the BIN file and reset.

Deprecated: No longer being updated.

func DatabaseVersion deprecated

func DatabaseVersion() string

DatabaseVersion returns the database version.

Deprecated: No longer being updated.

func GetAll deprecated

func GetAll(ipaddress string) map[string]string

GetAll will return all proxy fields based on the queried IP address.

Deprecated: No longer being updated.

func GetAs deprecated

func GetAs(ipaddress string) string

GetAs will return the autonomous system name based on the queried IP address.

Deprecated: No longer being updated.

func GetAsn deprecated

func GetAsn(ipaddress string) string

GetAsn will return the autonomous system number based on the queried IP address.

Deprecated: No longer being updated.

func GetCity deprecated

func GetCity(ipaddress string) string

GetCity will return the city name based on the queried IP address.

Deprecated: No longer being updated.

func GetCountryLong deprecated

func GetCountryLong(ipaddress string) string

GetCountryLong will return the country name based on the queried IP address.

Deprecated: No longer being updated.

func GetCountryShort deprecated

func GetCountryShort(ipaddress string) string

GetCountryShort will return the ISO-3166 country code based on the queried IP address.

Deprecated: No longer being updated.

func GetDomain deprecated

func GetDomain(ipaddress string) string

GetDomain will return the domain name based on the queried IP address.

Deprecated: No longer being updated.

func GetIsp deprecated

func GetIsp(ipaddress string) string

GetIsp will return the Internet Service Provider name based on the queried IP address.

Deprecated: No longer being updated.

func GetLastSeen deprecated

func GetLastSeen(ipaddress string) string

GetLastSeen will return the number of days that the proxy was last seen based on the queried IP address.

Deprecated: No longer being updated.

func GetProxyType deprecated

func GetProxyType(ipaddress string) string

GetProxyType will return the proxy type based on the queried IP address.

Deprecated: No longer being updated.

func GetRegion deprecated

func GetRegion(ipaddress string) string

GetRegion will return the region name based on the queried IP address.

Deprecated: No longer being updated.

func GetUsageType deprecated

func GetUsageType(ipaddress string) string

GetUsageType will return the usage type based on the queried IP address.

Deprecated: No longer being updated.

func IsProxy deprecated

func IsProxy(ipaddress string) int8

IsProxy checks whether the queried 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).

Deprecated: No longer being updated.

func ModuleVersion

func ModuleVersion() string

ModuleVersion returns the version of the component.

func Open deprecated

func Open(dbpath string) int8

Open takes the path to the IP2Proxy BIN database file. It will read all the metadata required to be able to extract the embedded proxy data.

Deprecated: No longer being updated.

func PackageVersion deprecated

func PackageVersion() string

PackageVersion returns the database type.

Deprecated: No longer being updated.

func Printrecord

func Printrecord(x IP2Proxyrecord)

Printrecord is used to output the proxy data for debugging purposes.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

func OpenDB

func OpenDB(dbpath string) (*DB, error)

OpenDB takes the path to the IP2Proxy BIN database file. It will read all the metadata required to be able to extract the embedded proxy data, and return the underlining DB object.

func (*DB) Close

func (d *DB) Close() error

func (*DB) DatabaseVersion

func (d *DB) DatabaseVersion() string

DatabaseVersion returns the database version.

func (*DB) GetAll

func (d *DB) GetAll(ipaddress string) (map[string]string, error)

GetAll will return all proxy fields based on the queried IP address.

func (*DB) GetAs

func (d *DB) GetAs(ipaddress string) (string, error)

GetAs will return the autonomous system name based on the queried IP address., err

func (*DB) GetAsn

func (d *DB) GetAsn(ipaddress string) (string, error)

GetAsn will return the autonomous system number based on the queried IP address., err

func (*DB) GetCity

func (d *DB) GetCity(ipaddress string) (string, error)

GetCity will return the city name based on the queried IP address.

func (*DB) GetCountryLong

func (d *DB) GetCountryLong(ipaddress string) (string, error)

GetCountryLong will return the country name based on the queried IP address.

func (*DB) GetCountryShort

func (d *DB) GetCountryShort(ipaddress string) (string, error)

GetCountryShort will return the ISO-3166 country code based on the queried IP address.

func (*DB) GetDomain

func (d *DB) GetDomain(ipaddress string) (string, error)

GetDomain will return the domain name based on the queried IP address.

func (*DB) GetIsp

func (d *DB) GetIsp(ipaddress string) (string, error)

GetIsp will return the Internet Service Provider name based on the queried IP address.

func (*DB) GetLastSeen

func (d *DB) GetLastSeen(ipaddress string) (string, error)

GetLastSeen will return the number of days that the proxy was last seen based on the queried IP address., err

func (*DB) GetProxyType

func (d *DB) GetProxyType(ipaddress string) (string, error)

GetProxyType will return the proxy type based on the queried IP address.

func (*DB) GetRegion

func (d *DB) GetRegion(ipaddress string) (string, error)

GetRegion will return the region name based on the queried IP address.

func (*DB) GetUsageType

func (d *DB) GetUsageType(ipaddress string) (string, error)

GetUsageType will return the usage type based on the queried IP address.

func (*DB) IsProxy

func (d *DB) IsProxy(ipaddress string) (int8, error)

IsProxy checks whether the queried 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).

func (*DB) PackageVersion

func (d *DB) PackageVersion() string

PackageVersion returns the database type.

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
}

The IP2Proxyrecord struct stores all of the available proxy info found in the IP2Proxy database.

Jump to

Keyboard shortcuts

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