objectmap

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2020 License: Apache-2.0 Imports: 3 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.

func NewIPDB

func NewIPDB(dbPath string) (*IPDB, error)

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 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