def country(hostname)
if (@databaseType == GEOIP_CITY_EDITION_REV0 ||
@databaseType == GEOIP_CITY_EDITION_REV1)
return city(hostname)
end
ip = hostname
if ip.kind_of?(String) && ip !~ /^[0-9.]*$/
ip = IPSocket.getaddress(hostname)
end
ipnum = iptonum(ip)
if (@databaseType != GEOIP_COUNTRY_EDITION &&
@databaseType != GEOIP_PROXY_EDITION &&
@databaseType != GEOIP_NETSPEED_EDITION)
throw "Invalid GeoIP database type, can't look up Country by IP"
end
code = seek_record(ipnum) - COUNTRY_BEGIN;
[ hostname,
ip,
code,
CountryCode[code],
CountryCode3[code],
CountryName[code],
CountryContinent[code] ]
end