geoip

package
v1.79.3 Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPToCountry

type IPToCountry interface {
	Close() error
	LookupISOCountryCode(address string) (location.CountryCode, error)
}

IPToCountry defines an abstraction for resolving the ISO country code given the string representation of an IP address.

type MaxmindDB

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

MaxmindDB provides access to GeoIP data via the maxmind geoip databases.

func OpenMaxmindDB

func OpenMaxmindDB(filepath string) (*MaxmindDB, error)

OpenMaxmindDB will use the provided filepath to open the target maxmind database.

func (*MaxmindDB) Close

func (m *MaxmindDB) Close() error

Close will disconnect the underlying connection to the database.

func (*MaxmindDB) LookupISOCountryCode

func (m *MaxmindDB) LookupISOCountryCode(address string) (location.CountryCode, error)

LookupISOCountryCode accepts an IP address.

type MockIPToCountry

type MockIPToCountry []location.CountryCode

MockIPToCountry provides a mock solution for looking up country codes in testplanet tests. This is done using the last byte of the ip address and mod'ing it into a country code.

func NewMockIPToCountry

func NewMockIPToCountry(countries []string) MockIPToCountry

NewMockIPToCountry creates a mock IPToCountry based on predefined country list.

func (MockIPToCountry) Close

func (m MockIPToCountry) Close() error

Close does nothing for the MockIPToCountry.

func (MockIPToCountry) LookupISOCountryCode

func (m MockIPToCountry) LookupISOCountryCode(address string) (location.CountryCode, error)

LookupISOCountryCode accepts an IP address.

Jump to

Keyboard shortcuts

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