Sha256: eec3097283c91b8d34cf70c57f595836218c1f77598121e4cf60ed2cdc6b7a69
Contents?: true
Size: 1.38 KB
Versions: 5
Compression:
Stored size: 1.38 KB
Contents
#!/usr/bin/env ruby lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib')) $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir) require 'geoip' data = '/usr/share/GeoIP/GeoIP.dat' data = ARGV.shift if ARGV[0] =~ /\.dat\Z/ geoip = GeoIP.new data req = case geoip.databaseType when GeoIP::Edition::CITY_REV1, GeoIP::Edition::CITY_REV0, GeoIP::Edition::CITY_REV1_V6 :city when GeoIP::Edition::REGION_REV0, GeoIP::Edition::REGION_REV1 :region when GeoIP::Edition::NETSPEED, GeoIP::Edition::NETSPEED_REV1 :netspeed when GeoIP::Edition::ISP, # All these looked up the same way GeoIP::Edition::ORG, GeoIP::Edition::ISP, GeoIP::Edition::DOMAIN, GeoIP::Edition::ACCURACYRADIUS, GeoIP::Edition::NETSPEED, GeoIP::Edition::USERTYPE, GeoIP::Edition::USERTYPE_V6, GeoIP::Edition::REGISTRAR, GeoIP::Edition::LOCATIONA, GeoIP::Edition::CITYCONF, GeoIP::Edition::COUNTRYCONF, GeoIP::Edition::REGIONCONF, GeoIP::Edition::POSTALCONF :isp when GeoIP::Edition::ASNUM :asn when GeoIP::Edition::COUNTRY, GeoIP::Edition::PROXY, GeoIP::Edition::COUNTRY_V6 :country else :asn end if ARGV.size > 0 ARGV.each { |a| p geoip.send(req, a) } else while (STDIN.isatty && print('geoip> '); ip = gets) ip.chomp! result = geoip.send(req, ip) p result end STDIN.isatty && puts end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
geoip-1.6.4 | bin/geoip |
geoip-1.6.3 | bin/geoip |
geoip-1.6.2 | bin/geoip |
geoip-1.6.1 | bin/geoip |
geoip-1.5.0 | bin/geoip |