ipread

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIpParseFailed = errors.New("failed to parse geo ip")
	ErrIpNotFound    = errors.New("ip not found")
)

Functions

func NewReader

func NewReader(config cfg.Config, logger log.Logger, name string) (*reader, error)

func ProvideMemoryProvider

func ProvideMemoryProvider(name string) *memoryProvider

Types

type GeoCity

type GeoCity struct {
	City        string `json:"city"`
	CountryCode string `json:"countryCode"`
	Ip          string `json:"ip"`
	TimeZone    string `json:"timeZone"`
}

type MemoryRecord

type MemoryRecord struct {
	CountryIso string `cfg:"country_iso"`
	CityName   string `cfg:"city_name"`
	TimeZone   string `cfg:"time_zone"`
}

type Provider

type Provider interface {
	City(ipAddress net.IP) (*geoip2.City, error)
}

func NewMaxmindProvider

func NewMaxmindProvider(config cfg.Config, _ log.Logger, name string) (Provider, error)

func NewMemoryProvider

func NewMemoryProvider(_ cfg.Config, _ log.Logger, name string) (Provider, error)

type ProviderFactory

type ProviderFactory func(config cfg.Config, logger log.Logger, name string) (Provider, error)

type Reader

type Reader interface {
	City(ipString string) (*GeoCity, error)
}

type ReaderSettings

type ReaderSettings struct {
	Provider string `cfg:"provider" default:"maxmind"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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