geodb

package
v5.0.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GeoDB

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

GeoDB maps IPs to their geological location based on MaxMinds GeoLite2 or GeoIP2 database.

func NewGeoDB

func NewGeoDB(licenseKey, downloadPath string) (*GeoDB, error)

NewGeoDB creates a new GeoDB for given license key.

func (*GeoDB) CountryCodeAndCity

func (db *GeoDB) CountryCodeAndCity(ip string) (string, string)

CountryCodeAndCity looks up the country code and city for given IP. If the IP is invalid it will return an empty string. The country code is returned in lowercase.

func (*GeoDB) Update

func (db *GeoDB) Update() error

Update downloads and unpacks the MaxMind GeoLite2 database.

func (*GeoDB) UpdateFromFile

func (db *GeoDB) UpdateFromFile(path string) error

UpdateFromFile updates GeoDB from given file instead of downloading the database.

Jump to

Keyboard shortcuts

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