Documentation ¶
Overview ¶
Go (cgo) interface to libgeoip
Index ¶
- Constants
- func GetRegionName(countryCode, regionCode string) string
- func SetCustomDirectory(dir string)
- type GeoIP
- func (gi *GeoIP) GetCountry(ip string) (cc string, netmask int)
- func (gi *GeoIP) GetCountry_v6(ip string) (cc string, netmask int)
- func (gi *GeoIP) GetName(ip string) (name string, netmask int)
- func (gi *GeoIP) GetNameV6(ip string) (name string, netmask int)
- func (gi *GeoIP) GetOrg(ip string) string
- func (gi *GeoIP) GetRecord(ip string) *GeoIPRecord
- func (gi *GeoIP) GetRegion(ip string) (string, string)
- type GeoIPRecord
Constants ¶
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 )
Variables ¶
This section is empty.
Functions ¶
func GetRegionName ¶
Returns the region name given a country code and region code
func SetCustomDirectory ¶
func SetCustomDirectory(dir string)
SetCustomDirectory sets the default location for the GeoIP .dat files used when calling OpenType()
Types ¶
type GeoIP ¶
type GeoIP struct {
// contains filtered or unexported fields
}
func Open ¶
Opens a GeoIP database by filename, all formats supported by libgeoip are supported though there are only functions to access some of the databases in this API. The database is opened in MEMORY_CACHE mode, if you need to optimize for memory instead of performance you should change this. If you don't pass a filename, it will try opening the database from a list of common paths.
func OpenType ¶
OpenType opens a specified GeoIP database type in the default location. Constants are defined for each database type (for example GEOIP_COUNTRY_EDITION).
func (*GeoIP) GetCountry ¶
Takes an IPv4 address string and returns the country code for that IP and the netmask for that IP range.
func (*GeoIP) GetCountry_v6 ¶
GetCountry_v6 works the same as GetCountry except for IPv6 addresses, be sure to load a database with IPv6 data to get any results.
func (*GeoIP) GetName ¶
Works on the ASN, Netspeed, Organization and probably other databases, takes and IP string and returns a "name" and the netmask.
func (*GeoIP) GetOrg ¶
Takes an IPv4 address string and returns the organization name for that IP. Requires the GeoIP organization database.
func (*GeoIP) GetRecord ¶
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