geoip2

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: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindDB

func FindDB() string

FindDB returns a guess at a directory path for GeoIP data files

Types

type GeoIP2

type GeoIP2 struct {
	// contains filtered or unexported fields
}

GeoIP2 contains the geoip implementation of the GeoDNS geo targeting interface

func New

func New(dir string) (g *GeoIP2, err error)

New returns a new GeoIP2 provider

func (*GeoIP2) GetASN

func (g *GeoIP2) GetASN(ip net.IP) (string, int, error)

GetASN returns the ASN for the IP (as a "as123" string) and the netmask

func (*GeoIP2) GetCountry

func (g *GeoIP2) GetCountry(ip net.IP) (country, continent string, netmask int)

GetCountry returns the country, continent and netmask for the given IP

func (*GeoIP2) GetLocation

func (g *GeoIP2) GetLocation(ip net.IP) (l *geo.Location, err error)

GetLocation returns a geo.Location object for the given IP

func (*GeoIP2) HasASN

func (g *GeoIP2) HasASN() (bool, error)

HasASN returns if we can do ASN lookups

func (*GeoIP2) HasCountry

func (g *GeoIP2) HasCountry() (bool, error)

HasCountry checks if the GeoIP country database is available

func (*GeoIP2) HasLocation

func (g *GeoIP2) HasLocation() (bool, error)

HasLocation returns if the city database is available to return lat/lon information for an IP

Jump to

Keyboard shortcuts

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