def country(hostname)
if (@database_type == GEOIP_CITY_EDITION_REV0 ||
@database_type == GEOIP_CITY_EDITION_REV1)
return city(hostname)
end
ip = lookup_ip(hostname)
ipnum = iptonum(ip)
if (@database_type != GEOIP_COUNTRY_EDITION &&
@database_type != GEOIP_PROXY_EDITION &&
@database_type != GEOIP_NETSPEED_EDITION)
throw "Invalid GeoIP database type, can't look up Country by IP"
end
code = (seek_record(ipnum) - COUNTRY_BEGIN)
Country.new(
hostname,
ip,
code,
CountryCode[code],
CountryCode3[code],
CountryName[code],
CountryContinent[code]
)
end