Class: Dap::Filter::FilterGeoIP2Asn
- Inherits:
-
Object
- Object
- Dap::Filter::FilterGeoIP2Asn
- Includes:
- BaseDecoder, GeoIP2Library
- Defined in:
- lib/dap/filter/geoip2.rb
Overview
Add GeoIP2 ASN and Org tags using the MaxMind GeoIP2::ASN database
Constant Summary
Constants included from GeoIP2Library
GeoIP2Library::GEOIP2_ASN, GeoIP2Library::GEOIP2_CITY, GeoIP2Library::GEOIP2_DIRS, GeoIP2Library::GEOIP2_ISP
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
Methods included from GeoIP2Library
Methods included from BaseDecoder
Methods included from Base
Instance Method Details
#decode(ip) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/dap/filter/geoip2.rb', line 142 def decode(ip) unless @@geo_asn raise "No MaxMind GeoIP2::ASN data found" end geo_hash = @@geo_asn.get(ip) return unless geo_hash ret = {} if geo_hash.include?("autonomous_system_number") ret["geoip2.asn.asn"] = "AS#{geo_hash["autonomous_system_number"]}" else ret["geoip2.asn.asn"] = "" end if geo_hash.include?("autonomous_system_organization") ret["geoip2.asn.asn_org"] = "#{geo_hash["autonomous_system_organization"]}" else ret["geoip2.asn.asn_org"] = "" end remove_empties(ret) end |