geoip

package
v0.0.0-...-3a545d7 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(geoip Interface) mux.MiddlewareFunc

Types

type Config

type Config struct {
	DB string `json:"db" usage:"path of the Maxmind GeoIP2Country database"`
}

Config contains the set of configuration options needed to configure looking up a users location.

func (Config) Open

func (c Config) Open() (Interface, error)

Open uses information from the Config to determine which type of lookup to use.

type Empty

type Empty struct{}

Empty provides an implementation that always returns empty information, regardless of ip.

func (Empty) Lookup

func (e Empty) Lookup(ip string) Info

type Info

type Info struct {
	CountryCode string
}

Info describes the various pieces of information that can be returned from a lookup.

func Extract

func Extract(ctx context.Context) Info

type Interface

type Interface interface {
	Lookup(ip string) Info
}

Interface defines how to resolve an IP to it's associated information.

type Maxmind

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

Maxmind provides logic for using Maxmind to resolve country information.

func CountryLite

func CountryLite(file string) (*Maxmind, error)

CountryLite uses the Maxmind GeoIP Country Lite database to resolve IP addresses to their associated country info.

func (*Maxmind) Lookup

func (m *Maxmind) Lookup(ip string) Info

Jump to

Keyboard shortcuts

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