providers

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: MIT Imports: 35 Imported by: 0

Documentation

Overview

This package has implementations for the most widely used IP geolocation databases.

Index

Constants

View Source
const (
	// Identifier for DB-IP.com provider.
	NameDBIPLite = "dbip_lite"

	// Identifier for ip2.org.
	NameIP2C = "ip2c"

	// Identifier for lite.ip2location.com.
	NameIP2Location = "ip2location_lite"

	// Identifier for ipinfo.io.
	NameIPInfo = "ipinfo"

	// Identifier for ipstack.com
	NameIPStack = "ipstack"

	// Identifier for MaxMind Geo2Lite databases.
	NameMaxmindLite = "maxmind_lite"

	// Identifier for software77.
	NameSoftware77 = "software77"
)

Variables

View Source
var (
	// ErrDatabaseIsNotReadyYet returns if you are trying to access
	// an offline provider but it haven't opened a database yet. For
	// example, it can be in process of downloading it.
	ErrDatabaseIsNotReadyYet = errors.New("database is not initialized yet")

	// ErrAuthTokenIsRequired is returned if you are trying to initialize
	// a provider which requires some token to work.
	ErrAuthTokenIsRequired = errors.New("auth token is required")

	// ErrNoFile is returned if provider has downloaded an archive with
	// database but this archive is empty.
	ErrNoFile = errors.New("cannot find a database file in downloaded archive")
)

Functions

func NewDBIPLite

func NewDBIPLite(httpClient topolib.HTTPClient, updateEvery time.Duration, baseDirectory string) topolib.OfflineProvider

NewDBIPLite returns a new instance which works with db-ip.com

Identifier: dbip_lite
Provider type: offline
Website: https://db-ip.com

DB-IP is quite a decent provider which has a results quality quite similar to MaxMind.

func NewIP2C

func NewIP2C(client topolib.HTTPClient) topolib.Provider

NewIP2C returns a new instance which works with ip2c.org

Identifier: ip2c
Provider type: online
Website: https://about.ip2c.org

ip2c is not really well-known but quite old and reliable webservice which provides you with IP geolocation data. Seems using Software77 databases. Has no cities, only countries.

func NewIP2Location

func NewIP2Location(client topolib.HTTPClient,
	updateEvery time.Duration,
	baseDirectory, authToken, dbCode string) (topolib.OfflineProvider, error)

NewIP2Location returns a new instance which works with databases from lite.ip2location.com

Identifier: ip2location_lite
Provider type: offline
Website: https://lite.ip2location.com

ip2location seems quite strange and somehow 'unstable' provider but quite popular. It is present mostly because of that fact: a lot of websites use it.

Please also pay attention to dbCode to supply. Topographer works with BIN format, IPv6 and at least level 3. If you are not sure which database to use, pass an empty string here.

func NewIPInfo

func NewIPInfo(client topolib.HTTPClient, authToken string) topolib.Provider

NewIPInfo returns a new instance which works with ipinfo.io

Identifier: ipinfo
Provider type: online
Website: https://ipinfo.io

ipinfo.io seems one of the most popular choices for REST API services.

func NewIPStack

func NewIPStack(client topolib.HTTPClient, authToken string, isSecure bool) (topolib.Provider, error)

NewIPStack returns a new instance which works with ipstack.com

Identifier: ipstack
Provider type: online
Website: https://ipstack.com

A brother/sister of ipinfo. Has a lot of big logos on its frontend page, sells https for money.

func NewMaxmindLite

func NewMaxmindLite(httpClient topolib.HTTPClient,
	updateEvery time.Duration,
	baseDirectory string,
	licenseKey string) (topolib.OfflineProvider, error)

NewMaxmindLite returns a new instance which works with lite databases from MaxMind.

Identifier: maxmind_lite
Provider type: offline
Website: https://maxmind.com

Probably a main choice if we speak on IP geolocation databases. The biggest player in this field.

func NewSoftware77

func NewSoftware77(client topolib.HTTPClient,
	updateEvery time.Duration,
	baseDirectory string) topolib.OfflineProvider

NewSoftware77 returns a new instance which works with databases from software77.

Identifier: software77
Provider type: offline
Website: https://software77.com

One of the most oldest databases available. Has no cities, only countries.

Types

This section is empty.

Jump to

Keyboard shortcuts

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