Class: Dap::Filter::FilterGeoIPAsn

Inherits:
Object
  • Object
show all
Includes:
BaseDecoder, GeoIPLibrary
Defined in:
lib/dap/filter/geoip.rb

Overview

Add GeoIP ASN tags using the MaxMind GeoIP::ASN database

Constant Summary

Constants included from GeoIPLibrary

GeoIPLibrary::GEOIP_ASN, GeoIPLibrary::GEOIP_ASN_DATABASE_PATH, GeoIPLibrary::GEOIP_CITY, GeoIPLibrary::GEOIP_CITY_DATABASE_PATH, GeoIPLibrary::GEOIP_DIRS, GeoIPLibrary::GEOIP_ORGS, GeoIPLibrary::GEOIP_ORG_DATABASE_PATH

Instance Attribute Summary

Attributes included from Base

#name, #opts

Instance Method Summary collapse

Methods included from BaseDecoder

#process

Methods included from Base

#initialize, #process

Instance Method Details

#decode(ip) ⇒ Object



117
118
119
120
121
122
123
124
# File 'lib/dap/filter/geoip.rb', line 117

def decode(ip)
  unless @@geo_asn
    raise "No MaxMind GeoIP::ASN data found"
  end
  geo_hash = @@geo_asn.look_up(ip)
  return unless (geo_hash and geo_hash[:name])
  { :asn => geo_hash[:name].split(' ')[0] }
end