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

Version Path
wmap-2.8.4 demos/filter_geoip.rb
wmap-2.8.3 demos/filter_geoip.rb
wmap-2.8.2 demos/filter_geoip.rb
wmap-2.8.1 demos/filter_geoip.rb
wmap-2.7.9 demos/filter_geoip.rb
wmap-2.7.7 demos/filter_geoip.rb
wmap-2.7.6 demos/filter_geoip.rb
wmap-2.7.2 demos/filter_geoip.rb
wmap-2.7.1 demos/filter_geoip.rb
wmap-2.7.0 demos/filter_geoip.rb
wmap-2.6.9 demos/filter_geoip.rb
wmap-2.6.8 demos/filter_geoip.rb
wmap-2.6.7 demos/filter_geoip.rb
wmap-2.6.6 demos/filter_geoip.rb
wmap-2.6.5 demos/filter_geoip.rb
wmap-2.6.4 demos/filter_geoip.rb
wmap-2.6.3 demos/filter_geoip.rb
wmap-2.6.2 demos/filter_geoip.rb
wmap-2.6.1 demos/filter_geoip.rb
wmap-2.6.0 demos/filter_geoip.rb