Sha256: c2d264e8536d779270ea9e680a848ff22ed124e8beeadde65bf19fb39395c606
Contents?: true
Size: 449 Bytes
Versions: 4
Compression:
Stored size: 449 Bytes
Contents
# # This program walks the specified file and dumps it in IP order # require 'geoip' ARGV.each do |file| g = GeoIP.new(file) g.each_by_ip do |ip, val| ip_str = if ip >= (1<<32) (('%032X'%ip).scan(/..../)*':').sub(/\A(0000:)+/, '::') # An IPv6 address else '%d.%d.%d.%d' % [ip].pack('N').unpack('C4') end puts "#{ip_str}\t#{val ? val.to_hash.to_a.sort.map{|n,v| "#{n}=#{v.inspect}"}*', ' : 'Unassigned'}" end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
geoip-1.6.4 | test/test_file.rb |
geoip-1.6.3 | test/test_file.rb |
geoip-1.6.2 | test/test_file.rb |
geoip-1.6.1 | test/test_file.rb |