Documentation
¶
Overview ¶
Package geoip provides MaxMind GeoIP2/GeoLite2 database lookups for IP geolocation and ASN enrichment.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultReader = &Reader{}
DefaultReader is the process-wide GeoIP reader. Scalar functions reference this instance; it starts empty and is populated by Load().
Functions ¶
Types ¶
type ASNRecord ¶
type ASNRecord struct {
Number uint `maxminddb:"autonomous_system_number"`
Organization string `maxminddb:"autonomous_system_organization"`
}
ASNRecord mirrors the MaxMind GeoIP2 ASN database schema.
type CityRecord ¶
type CityRecord struct {
Country struct {
ISOCode string `maxminddb:"iso_code"`
Names map[string]string `maxminddb:"names"`
} `maxminddb:"country"`
City struct {
Names map[string]string `maxminddb:"names"`
} `maxminddb:"city"`
Subdivisions []struct {
ISOCode string `maxminddb:"iso_code"`
Names map[string]string `maxminddb:"names"`
} `maxminddb:"subdivisions"`
Postal struct {
Code string `maxminddb:"code"`
} `maxminddb:"postal"`
Location struct {
Latitude float64 `maxminddb:"latitude"`
Longitude float64 `maxminddb:"longitude"`
TimeZone string `maxminddb:"time_zone"`
} `maxminddb:"location"`
Continent struct {
Code string `maxminddb:"code"`
Names map[string]string `maxminddb:"names"`
} `maxminddb:"continent"`
}
CityRecord mirrors the MaxMind GeoIP2 City database schema.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader wraps MaxMind MMDB database handles with thread-safe access.
func (*Reader) LookupASN ¶
LookupASN queries the ASN database for the given IP. Returns nil if no ASN database is loaded or the IP is not found.
func (*Reader) LookupCity ¶
func (r *Reader) LookupCity(ip net.IP) *CityRecord
LookupCity queries the city database for the given IP. Returns nil if no city database is loaded or the IP is not found.
Click to show internal directories.
Click to hide internal directories.