geo

package
v3.3.3 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const MaxDistance = 360

MaxDistance is the distance returned if Distance() is called with a nil location

Variables

This section is empty.

Functions

This section is empty.

Types

type Location

type Location struct {
	Country     string
	Continent   string
	RegionGroup string
	Region      string
	Latitude    float64
	Longitude   float64
	Netmask     int
}

Location is the struct the GeoIP provider packages use to return location details for an IP.

func (*Location) Distance

func (l *Location) Distance(to *Location) float64

Distance returns the distance between the two locations

func (*Location) MaxDistance

func (l *Location) MaxDistance() float64

MaxDistance() returns the MaxDistance constant

type Provider

type Provider interface {
	HasCountry() (bool, error)
	GetCountry(ip net.IP) (country, continent string, netmask int)
	HasASN() (bool, error)
	GetASN(net.IP) (asn string, netmask int, err error)
	HasLocation() (bool, error)
	GetLocation(ip net.IP) (location *Location, err error)
}

Provider is the interface for geoip providers

Jump to

Keyboard shortcuts

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