class Wmap::GeoIPTracker

Wrapper class of the 'GeoIP' library - geoip.rubyforge.org/ For detail explanation of Geographic information of an IP address (GeoIP) and its data repository, please refer to the vendor MaxMind (www.maxmind.com)

Constants

Db_asn
Db_city

This product includes GeoLite data created by MaxMind, available from <a href=“http://www.maxmind.comwww.maxmind.com”>http://www.maxmind.com>.

Db_country

Attributes

db[RW]
verbose[RW]

Public Class Methods

new(params = {}) click to toggle source

Set default instance variables

# File lib/wmap/geoip_tracker.rb, line 25
def initialize (params = {})           
        @verbose=params.fetch(:verbose, false)
        @db=params.fetch(:db, Db_city)
end

Public Instance Methods

asn(object) click to toggle source

Wrapper for the Ruby GeoIP ASN class - return data structure below on successful lookup Struct.new(:number, :asn)

# File lib/wmap/geoip_tracker.rb, line 61
def asn(object)        
        puts "Perform GeoIP ASN lookup on: #{object}" if @verbose
        begin
                object=object.strip
                raise "Unknown object format - only valid hostname or IP is accepted: #{object}" unless is_ip?(object) or is_fqdn?(object)
                GeoIP.new(Db_asn).asn(object)
        rescue Exception => ee
                puts "Exception on method asn: #{object}" if @verbose
                return nil
        end
end
country(object) click to toggle source

Wrapper for the Ruby GeoIP Country class - return data structure below on successful lookup Struct.new(:request, :ip, :country_code, :country_code2, :country_code3, :country_name, :continent_code)

# File lib/wmap/geoip_tracker.rb, line 47
def country(object)    
        puts "Perform GeoIP country lookup on: #{object}" if @verbose
        begin
                object=object.strip
                raise "Unknown object format - only valid hostname or IP is accepted: #{object}" unless is_ip?(object) or is_fqdn?(object)
                GeoIP.new(Db_country).country(object)
        rescue Exception => ee
                puts "Exception on method country: #{object}" if @verbose
                return nil
        end
end
query(object)
Alias for: city