objectmap

package
v1.80.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 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"`
}

IPInfo represents the geolocation data from maxmind db.

type MockReader

type MockReader struct{}

MockReader is a mock implementation of maxmind database reader interface.

func (*MockReader) Close

func (mr *MockReader) Close() error

Close closes underlying connection.

func (*MockReader) Lookup

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