objectmap

package
v1.5.1-rc-2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Error = errs.Class("objectmap error")

Error is the default error class for objectmap.

Functions

func ValidateIP

func ValidateIP(ipAddress string) (net.IP, error)

ValidateIP validate and remove port from IP address.

Types

type IPDB

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

IPDB holds the database file path and its reader.

architecture: Database

func NewIPDB

func NewIPDB(reader Reader) *IPDB

NewIPDB creates a new IPMapper instance.

func (*IPDB) Close

func (mapper *IPDB) Close() (err error)

Close closes the IPMapper reader.

func (*IPDB) GetIPInfos

func (mapper *IPDB) GetIPInfos(ipAddress string) (_ *IPInfo, err error)

GetIPInfos returns the geolocation information from an IP address.

type IPInfo

type IPInfo struct {
	Location struct {
		Latitude  float64 `maxminddb:"latitude"`
		Longitude float64 `maxminddb:"longitude"`
	} `maxminddb:"location"`
	Postal struct {
		Code string `maxminddb:"code"`
	} `maxminddb:"postal"`
	Country struct {
		IsoCode string `maxminddb:"iso_code"`
	} `maxminddb:"country"`
}

IPInfo represents the geolocation data from maxmind db.

type MockReader added in v1.3.0

type MockReader struct{}

MockReader is a mock implementation of maxmind database reader interface.

func (*MockReader) Close added in v1.3.0

func (mr *MockReader) Close() error

Close closes underlying connection.

func (*MockReader) Lookup added in v1.3.0

func (mr *MockReader) Lookup(ip net.IP, result interface{}) error

Lookup retrieves the database record for ip and stores it in the value pointed to by result.

type Reader

type Reader interface {
	Lookup(ip net.IP, result interface{}) error
	Close() error
}

Reader is a maxmind database reader interface.

Jump to

Keyboard shortcuts

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