Sha256: 4a54e09c2b15dbb15a7f1fb596016ece60df66cf124f61cfc0a2e38d8780abf8
Contents?: true
Size: 793 Bytes
Versions: 34
Compression:
Stored size: 793 Bytes
Contents
# Perform GEOIP info lookup, based on Maxmind GeoIP database # Usage: ruby filter_geoip.rb [file_wdump_csv] require "wmap" verbose=false tracker = Wmap::GeoIPTracker.new(:verbose=>false) #puts "IP, GeoIP Location" f_ips = File.open(ARGV[0], 'r') f_ips.each do |line| ip=line.chomp.split(',')[1] info=String.new if tracker.is_ip?(ip) puts "IP: #{ip}" if verbose ctr=tracker.country(ip) info = info + " " + ctr.country_code3 unless ctr.country_code3.nil? citi=tracker.city(ip) info=info+" "+citi.region_name unless citi.nil? or citi.region_name.nil? info=info+" "+citi.city_name unless citi.nil? or citi.city_name.nil? info=info+" "+citi.postal_code unless citi.nil? or citi.postal_code.nil? puts "#{line.chomp}, #{info}" else puts "#{line.chomp}," end end f_ips.close
Version data entries
34 entries across 34 versions & 1 rubygems