import "github.com/abh/geoip"
Go (cgo) interface to libgeoip
const ( GEOIP_COUNTRY_EDITION = 1 GEOIP_REGION_EDITION_REV0 = 7 GEOIP_CITY_EDITION_REV0 = 6 GEOIP_ORG_EDITION = 5 GEOIP_ISP_EDITION = 4 GEOIP_CITY_EDITION_REV1 = 2 GEOIP_REGION_EDITION_REV1 = 3 GEOIP_PROXY_EDITION = 8 GEOIP_ASNUM_EDITION = 9 GEOIP_NETSPEED_EDITION = 10 GEOIP_DOMAIN_EDITION = 11 GEOIP_COUNTRY_EDITION_V6 = 12 GEOIP_LOCATIONA_EDITION = 13 GEOIP_ACCURACYRADIUS_EDITION = 14 GEOIP_CITYCONFIDENCE_EDITION = 15 GEOIP_CITYCONFIDENCEDIST_EDITION = 16 GEOIP_LARGE_COUNTRY_EDITION = 17 GEOIP_LARGE_COUNTRY_EDITION_V6 = 18 GEOIP_ASNUM_EDITION_V6 = 21 GEOIP_ISP_EDITION_V6 = 22 GEOIP_ORG_EDITION_V6 = 23 GEOIP_DOMAIN_EDITION_V6 = 24 GEOIP_LOCATIONA_EDITION_V6 = 25 GEOIP_REGISTRAR_EDITION = 26 GEOIP_REGISTRAR_EDITION_V6 = 27 GEOIP_USERTYPE_EDITION = 28 GEOIP_USERTYPE_EDITION_V6 = 29 GEOIP_CITY_EDITION_REV1_V6 = 30 GEOIP_CITY_EDITION_REV0_V6 = 31 GEOIP_NETSPEED_EDITION_REV1 = 32 GEOIP_NETSPEED_EDITION_REV1_V6 = 33 )
GeoIPDBTypes enum in GeoIP.h
const ( GEOIP_STANDARD = 0 GEOIP_MEMORY_CACHE = 1 GEOIP_CHECK_CACHE = 2 GEOIP_INDEX_CACHE = 4 GEOIP_MMAP_CACHE = 8 )
GeoIPOptions enum in GeoIP.h
Returns the region name given a country code and region code
SetCustomDirectory sets the default location for the GeoIP .dat files used when calling OpenType()
type GeoIP struct {
// contains filtered or unexported fields
}
Default convenience wrapper around OpenDb
Opens a GeoIP database by filename with specified GeoIPOptions flag. All formats supported by libgeoip are supported though there are only functions to access some of the databases in this API. If you don't pass a filename, it will try opening the database from a list of common paths.
OpenType opens a specified GeoIP database type in the default location and the 'memory cache' flag. Use OpenTypeFlag() to specify flag.
OpenType opens a specified GeoIP database type in the default location with the specified GeoIPOptions flag. Constants are defined for each database type (for example GEOIP_COUNTRY_EDITION).
Takes an IPv4 address string and returns the country code for that IP and the netmask for that IP range.
GetCountry_v6 works the same as GetCountry except for IPv6 addresses, be sure to load a database with IPv6 data to get any results.
Works on the ASN, Netspeed, Organization and probably other databases, takes and IP string and returns a "name" and the netmask.
Same as GetName() but for IPv6 addresses.
Takes an IPv4 address string and returns the organization name for that IP. Requires the GeoIP organization database.
func (gi *GeoIP) GetRecord(ip string) *GeoIPRecord
Returns the "City Record" for an IP address. Requires the GeoCity(Lite) database - http://www.maxmind.com/en/city
Returns the country code and region code for an IP address. Requires the GeoIP Region database.
type GeoIPRecord struct { CountryCode string CountryCode3 string CountryName string Region string City string PostalCode string Latitude float32 Longitude float32 MetroCode int AreaCode int CharSet int ContinentCode string }
Path | Synopsis |
---|---|
ex |
Package geoip imports 7 packages (graph) and is imported by 52 packages. Updated 2016-08-24. Refresh now. Tools for package owners.