class Enricher::Encoder
Public Class Methods
asn(ip)
click to toggle source
# File lib/enricher/encoder.rb, line 61 def asn(ip) @@geoASN ||= GeoIP.new("#{Enricher::DATA_PATH}/GeoIPASNum.dat") return @@geoASN.asn(ip).number rescue "--" end
asn_company(ip)
click to toggle source
# File lib/enricher/encoder.rb, line 66 def asn_company(ip) @@geoASN ||= GeoIP.new("#{Enricher::DATA_PATH}/GeoIPASNum.dat") return @@geoASN.asn(ip).asn rescue "--" end
aton(a)
click to toggle source
# File lib/enricher/encoder.rb, line 39 def aton(a) IPAddr.new(a).to_i end
bogon?(ip)
click to toggle source
# File lib/enricher/encoder.rb, line 51 def bogon?(ip) @@bogon_type ||= self.bogon_type @@bogon ||= Bogon.new(@@bogon_type) return @@bogon.contains?(ip) end
bogon_type(bogon_sym=:ipv4)
click to toggle source
# File lib/enricher/encoder.rb, line 57 def bogon_type(bogon_sym=:ipv4) bogon_sym end
cc3(ip)
click to toggle source
# File lib/enricher/encoder.rb, line 71 def cc3(ip) @@geoCoder ||= GeoIP.new("#{Enricher::DATA_PATH}/GeoIP.dat") return @@geoCoder.country(ip).country_code3 end
cdn?(hostname)
click to toggle source
# File lib/enricher/encoder.rb, line 91 def cdn?(hostname) return Enricher::CDN.contains?(hostname) end
encode(ip)
click to toggle source
# File lib/enricher/encoder.rb, line 9 def encode(ip) @@geoASN ||= GeoIP.new("#{Enricher::DATA_PATH}/GeoIPASNum.dat") @@geoCoder ||= GeoIP.new("#{Enricher::DATA_PATH}/GeoIP.dat") @@geoCoderCity ||= GeoIP.new("#{Enricher::DATA_PATH}/GeoLiteCity.dat") @@res ||= Enricher::Resolver.new @@bogon_type ||= self.bogon_type @@bogon ||= Bogon.new(@@bogon_type) asn = @@geoASN.asn(ip).number rescue "--" {:ip => IPAddr.new(ip).to_i, :asn => asn, :asn_rank => Enricher::BGPRanking.rank?(asn), :geoip => @@geoCoder.country(ip).country_code3, :bogon => @@bogon.contains?(ip)} end
encode_online(ip)
click to toggle source
# File lib/enricher/encoder.rb, line 24 def encode_online(ip) @@geoASN ||= GeoIP.new("#{Enricher::DATA_PATH}/GeoIPASNum.dat") @@geoCoder ||= GeoIP.new("#{Enricher::DATA_PATH}/GeoIP.dat") @@geoCoderCity ||= GeoIP.new("#{Enricher::DATA_PATH}/GeoLiteCity.dat") @@res ||= Enricher::Resolver.new @@bogon_type ||= self.bogon_type(:live) @@bogon ||= Bogon.new(@@bogon_type) asn = @@geoASN.asn(ip).number rescue "--" reverse_hostname = self.reverse(ip) rescue "" {:ip => IPAddr.new(ip).to_i, :asn => asn, :asn_rank => Enricher::BGPRanking.rank?(asn), :geoip => @@geoCoder.country(ip).country_code3, :bogon => @@bogon.contains?(ip), :reverse => reverse_hostname, :cdn => self.cdn?(reverse_hostname)} end
latitude(ip)
click to toggle source
# File lib/enricher/encoder.rb, line 76 def latitude(ip) @@geoCoderCity ||= GeoIP.new("#{Enricher::DATA_PATH}/GeoIP.dat") return @@geoCoderCity.city(ip).latitude end
longitude(ip)
click to toggle source
# File lib/enricher/encoder.rb, line 81 def longitude(ip) @@geoCoderCity ||= GeoIP.new("#{Enricher::DATA_PATH}/GeoIP.dat") return @@geoCoderCity.city(ip).longitude end
ntoa(a)
click to toggle source
# File lib/enricher/encoder.rb, line 43 def ntoa(a) IPAddr.new(a, Socket::AF_INET).to_s end
rank?(asn)
click to toggle source
# File lib/enricher/encoder.rb, line 47 def rank?(asn) Enricher::BGPRanking.rank?(asn) end
reverse(ip)
click to toggle source
# File lib/enricher/encoder.rb, line 86 def reverse(ip) @@res ||= Enricher::Resolver.new return @@res.reverse?(ip) end