ip2proxy

package module
v0.0.0-...-1520a10 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2018 License: MIT Imports: 7 Imported by: 1

README

ip2proxy

IP2Location.com Proxy database parser for Golang

Build Status Go Report Card GoDoc

Install & prerequisites

  • Get the library:
go get -u github.com/etf1/ip2proxy

Use it

package main

import (
	"github.com/etf1/ip2proxy"
)

// let's go !
func main() {
	db, err := ip2proxy.Open("/where/you/unzipped/IP2PROXY-LITE-PX4.BIN")
	if err != nil {
		panic(err)
	}
	res, err := db.LookupIPV4Dot("2.7.154.188")
	if err != nil {
		panic(err)
	}
	if res.Proxy == ip2proxy.ProxyTOR {
		println("2.7.154.188 is a TOR output node !")
	} else {
	    println("2.7.154.188 is NOT a TOR output node")	
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB holds a parsed database instance

func FromBytes

func FromBytes(data []byte) (*DB, error)

FromBytes takes a byte slice corresponding to a IP2Proxy file and returns the parsed DB object.

func Open

func Open(path string) (*DB, error)

Open will opens a db file and parses it

func (*DB) Count

func (db *DB) Count() uint32

Count returns the number of records in database

func (*DB) Date

func (db *DB) Date() time.Time

Date returns the date of the current db version

func (*DB) LookupIPV4

func (db *DB) LookupIPV4(ip net.IP) (*Result, error)

LookupIPV4 lookups a net.IP ipv4 address in database

func (*DB) LookupIPV4Dot

func (db *DB) LookupIPV4Dot(ip string) (*Result, error)

LookupIPV4Dot lookups a dot notation (1.2.3.4) ipv4 address in database

func (*DB) LookupIPV4Num

func (db *DB) LookupIPV4Num(ip uint32) (*Result, error)

LookupIPV4Num lookups a numeric ipv4 address in database

func (*DB) Type

func (db *DB) Type() DbType

Type gets the db type id

func (*DB) TypeName

func (db *DB) TypeName() string

TypeName gets the db type name

func (*DB) Version

func (db *DB) Version() string

Version returns the current db version name

type DbType

type DbType uint8

DbType is the type of db

const (
	// UnknownDbType is the type for unknown db type
	UnknownDbType DbType = 0
	// PX1 is the IP2Proxy IP-COUNTRY database
	PX1 DbType = 1
	// PX2 is the IP2Proxy IP-PROXYTYPE-COUNTRY database
	PX2 DbType = 2
	// PX3 is the IP2Proxy IP-PROXYTYPE-COUNTRY-REGION-CITY database
	PX3 DbType = 3
	// PX4 is the P2Proxy IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP database
	PX4 DbType = 4
)

type ProxyType

type ProxyType uint8

ProxyType is the type of proxy detected

const (
	// ProxyNA are hosts which proxy status is not available (db without the info or invalid data).
	ProxyNA ProxyType = iota
	// ProxyNOT are hosts not detected as proxy.
	ProxyNOT
	// ProxyVPN are Anonymizing VPN services. These services offer users a publicly accessible VPN for the purpose of
	// hiding their IP address.
	ProxyVPN
	// ProxyTOR are Tor Exit Nodes. The Tor Project is an open network used by those who wish to maintain anonymity.
	ProxyTOR
	// ProxyDCH Are Hosting Provider, Data Center or Content Delivery Network. Since hosting providers and data centers
	// can serve to provide anonymity, the Anonymous IP database flags IP addresses associated with them.
	ProxyDCH
	// ProxyPUB are Public Proxies. These are services which make connection requests on a user's behalf.
	// Proxy server software can be configured by the administrator to listen on some specified port.
	// These differ from VPNs in that the proxies usually have limited functions compare to VPNs.
	ProxyPUB
	// ProxyWEB are Web Proxies. These are web services which make web requests on a user's behalf.
	// These differ from VPNs or Public Proxies in that they are simple web-based proxies rather than operating at the IP address and other ports level.
	ProxyWEB
)

type Result

type Result struct {
	IP          string
	Country     *string
	CountryCode *string
	City        *string
	ISP         *string
	Region      *string
	Proxy       ProxyType
}

Result holds the lookup results

Jump to

Keyboard shortcuts

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