mmdb

package
v0.0.0-...-5e0ec4f Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2020 License: MIT, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASNDefaultQuery

type ASNDefaultQuery struct {
	AutonomousSystemNumber       uint   `maxminddb:"autonomous_system_number"`
	AutonomousSystemOrganization string `maxminddb:"autonomous_system_organization"`
}

type DB

type DB struct {
	Updater *updater.Config // Holds all notification channels
	Config  *config.Config  // Shared default configuration

	ErrUnavailable error // ErrUnavailable may be returned by DB.Lookup when the database
	// contains filtered or unexported fields
}

DB is the IP geolocation database.

func NewDefaultConfig

func NewDefaultConfig(c *config.Config, productID string) *DB

func (*DB) Close

func (d *DB) Close()

Close closes the database.

func (*DB) GenerateUpdateURL

func (d *DB) GenerateUpdateURL(productID string) string

Generate the update url for the current product database.

func (*DB) Lookup

func (d *DB) Lookup(addr net.IP, result interface{}) error

Lookup performs a database lookup of the given IP address, and stores the response into the result value. The result value must be a struct with specific fields and tags as described here: https://godoc.org/github.com/oschwald/maxminddb-golang#Reader.Lookup

See the DefaultQuery for an example of the result struct.

func (*DB) Start

func (d *DB) Start() (*updater.Config, error)

type DefaultQuery

type DefaultQuery struct {
	Continent struct {
		Code  string            `maxminddb:"code"`
		Names map[string]string `maxminddb:"names"`
	} `maxminddb:"continent"`
	Country struct {
		ISOCode           string            `maxminddb:"iso_code"`
		ContinentCode     string            `maxminddb:"continent_code"`
		IsInEuropeanUnion bool              `maxminddb:"is_in_european_union"`
		Names             map[string]string `maxminddb:"names"`
	} `maxminddb:"country"`
	Region []struct {
		ISOCode string            `maxminddb:"iso_code"`
		Names   map[string]string `maxminddb:"names"`
	} `maxminddb:"subdivisions"`
	City struct {
		Names map[string]string `maxminddb:"names"`
	} `maxminddb:"city"`
	Location struct {
		Latitude          float64 `maxminddb:"latitude"`
		Longitude         float64 `maxminddb:"longitude"`
		AccuracyRadius    uint    `maxminddb:"accuracy_radius"`
		MetroCode         uint    `maxminddb:"metro_code"`
		TimeZone          string  `maxminddb:"time_zone"`
		PopulationDensity uint    `maxminddb:"population_density"`
	} `maxminddb:"location"`
	Traits struct {
		AutonomousSystemNumber       uint   `maxminddb:"autonomous_system_number"`
		AutonomousSystemOrganization string `maxminddb:"autonomous_system_organization"`
		Domain                       string `maxminddb:"domain"`
		IsAnonymous                  bool   `maxminddb:"is_anonymous"`
		IsAnonymousProxy             bool   `maxminddb:"is_anonymous_proxy"`
		IsAnonymousVPN               bool   `maxminddb:"is_anonymous_vpn"`
		IsHostingProvider            bool   `maxminddb:"is_hosting_provider"`
		IsPublicProxy                bool   `maxminddb:"is_public_proxy"`
		IsSatelliteProvider          bool   `maxminddb:"is_satellite_provider"`
		IsTorExitNode                bool   `maxminddb:"is_tor_exit_node"`
		ISP                          string `maxminddb:"isp"`
		IpAddress                    string `maxminddb:"ip_address"`
		Network                      string `maxminddb:"network"`
		Organization                 string `maxminddb:"organization"`
		StaticIpScore                string `maxminddb:"static_ip_score"`
		UserCount                    string `maxminddb:"user_count"`
		UserType                     string `maxminddb:"user_type"`
	} `maxminddb:"traits"`
	Postal struct {
		Code string `maxminddb:"code"`
	} `maxminddb:"postal"`
}

DefaultQuery is the default query used for database lookups. https://dev.maxmind.com/geoip/geoip2/geoip2-city-country-csv-databases/

type TorDefaultQuery

type TorDefaultQuery struct {
	IsTorUser bool
}

Jump to

Keyboard shortcuts

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