geoip

package
Version: v0.8.12 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: AGPL-3.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ASOrgUnknown added in v0.7.19

func ASOrgUnknown(asOrg string) bool

ASOrgUnknown return whether the given AS Org string actually is meant to mean that the AS Org is unknown.

func PrimitiveNetworkProximity

func PrimitiveNetworkProximity(from net.IP, to net.IP, ipVersion uint8) int

PrimitiveNetworkProximity calculates the numerical distance between two IP addresses. Returns a proximity value between 0 (far away) and 100 (nearby).

Types

type Coordinates added in v0.7.1

type Coordinates struct {
	AccuracyRadius uint16  `maxminddb:"accuracy_radius"`
	Latitude       float64 `maxminddb:"latitude"`
	Longitude      float64 `maxminddb:"longitude"`
}

Coordinates holds geographic coordinates and their estimated accuracy.

type Location

type Location struct {
	Continent struct {
		Code string `maxminddb:"code"`
	} `maxminddb:"continent"`
	Country struct {
		ISOCode string `maxminddb:"iso_code"`
	} `maxminddb:"country"`
	Coordinates                  Coordinates `maxminddb:"location"`
	AutonomousSystemNumber       uint        `maxminddb:"autonomous_system_number"`
	AutonomousSystemOrganization string      `maxminddb:"autonomous_system_organization"`
}

Location holds information regarding the geographical and network location of an IP address.

func GetLocation

func GetLocation(ip net.IP) (*Location, error)

GetLocation returns Location data of an IP address.

func (*Location) EstimateNetworkProximity

func (l *Location) EstimateNetworkProximity(to *Location) (proximity float32)

EstimateNetworkProximity aims to calculate the distance between two network locations. Returns a proximity value between 0 (far away) and 100 (nearby).

func (*Location) FillMissingInfo added in v0.7.1

func (l *Location) FillMissingInfo()

FillMissingInfo tries to fill missing location information based on the available existing information.

Jump to

Keyboard shortcuts

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