geoip

package
v1.6.13 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ASOrgUnknown

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 IsInitialized

func IsInitialized(v6, wait bool) bool

IsInitialized returns whether the geoip database has been initialized.

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 ContinentInfo

type ContinentInfo struct {
	Code   string
	Region string
	Name   string
}

ContinentInfo holds additional information about continents.

type Coordinates

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 CountryInfo

type CountryInfo struct {
	Code      string `maxminddb:"iso_code"`
	Name      string
	Center    Coordinates
	Continent ContinentInfo
}

CountryInfo holds additional information about countries.

func GetCountryInfo

func GetCountryInfo(countryCode string) CountryInfo

GetCountryInfo returns the country info of the given country code, or nil in case the data does not exist.

type Location

type Location struct {
	Country                      CountryInfo `maxminddb:"country"`
	Coordinates                  Coordinates `maxminddb:"location"`
	AutonomousSystemNumber       uint        `maxminddb:"autonomous_system_number"`
	AutonomousSystemOrganization string      `maxminddb:"autonomous_system_organization"`
	IsAnycast                    bool        `maxminddb:"is_anycast"`
	IsSatelliteProvider          bool        `maxminddb:"is_satellite_provider"`
	IsAnonymousProxy             bool        `maxminddb:"is_anonymous_proxy"`
}

Location holds information regarding the geographical and network location of an IP address. TODO: We are currently re-using the Continent-Code for the region. Update this and all dependencies.

func GetLocation

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

GetLocation returns Location data of an IP address.

func (*Location) AddCountryInfo

func (l *Location) AddCountryInfo()

AddCountryInfo adds missing country information to the location.

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

func (l *Location) IsRegionalNeighbor(other *Location) bool

IsRegionalNeighbor returns whether the supplied location is a regional neighbor.

type Region

type Region struct {
	ID        string
	Name      string
	Neighbors []string
}

Region defines a geographic region and neighboring regions.

Jump to

Keyboard shortcuts

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