objectmap

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: AGPL-3.0 Imports: 7 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

This section is empty.

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(ctx context.Context, hostOrIP 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