Class: Dap::Filter::FilterGeoIP2Isp
- Inherits:
-
Object
- Object
- Dap::Filter::FilterGeoIP2Isp
- Includes:
- BaseDecoder, GeoIP2Library
- Defined in:
- lib/dap/filter/geoip2.rb
Overview
Add GeoIP2 ISP tags using the MaxMind GeoIP2::ISP 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
find_db, #get_maxmind_data, #remove_empties
Methods included from BaseDecoder
Methods included from Base
Instance Method Details
#decode(ip) ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/dap/filter/geoip2.rb', line 182 def decode(ip) unless @@geo_isp raise "No MaxMind GeoIP2::ISP data found" end geo_hash = get_maxmind_data(@@geo_isp, ip) return unless geo_hash ret = {} if geo_hash.include?("autonomous_system_number") ret["geoip2.isp.asn"] = "AS#{geo_hash["autonomous_system_number"]}" else ret["geoip2.isp.asn"] = "" end if geo_hash.include?("autonomous_system_organization") ret["geoip2.isp.asn_org"] = geo_hash["autonomous_system_organization"] else ret["geoip2.isp.asn_org"] = "" end if geo_hash.include?("isp") ret["geoip2.isp.isp"] = geo_hash["isp"] else ret["geoip2.isp.isp"] = "" end if geo_hash.include?("organization") ret["geoip2.isp.org"] = geo_hash["organization"] else ret["geoip2.isp.org"] = "" end remove_empties(ret) end |