geoip

package
v1.27.8-rc.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package geoip provides an automatically updating MaxMind GeoIP2 database provider.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

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

func NewGeoLite2CityProvider

func NewGeoLite2CityProvider(ctx context.Context, accountID int, licenseKey string, directory string) (*Provider, error)

NewGeoLite2CityProvider returns a new GeoIP2 database provider for the GeoLite2-City database. The database will be stored in the given directory (which should exist) and refreshed every 7 days.

func (*Provider) City

func (p *Provider) City(ip net.IP) (*geoip2.City, error)

func (*Provider) Serve

func (p *Provider) Serve(ctx context.Context) error

Serve downloads the GeoIP2 database and keeps it up to date. It will return when the context is canceled.

Jump to

Keyboard shortcuts

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