Sha256: dd5b2d39cac082360b7612307d6fa281c490c28388eea1595b236fcd45647c08
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true require "date" require "dnsdb" module Ukemi module Services class DNSDB < Service private def config_keys %w[DNSDB_API_KEY] end def api @api ||= ::DNSDB::API.new end def lookup_by_ip(data) results = api.lookup.rdata(type: "ip", value: data, rrtype: "A") results.map do |result| rrname = result["rrname"] # Remove the last dot (e.g. "example.com.") data = rrname[0..-2] Record.new( data: data, first_seen: Time.at(result["time_first"]).to_date.to_s, last_seen: Time.at(result["time_last"]).to_date.to_s, source: name ) end end def lookup_by_domain(data) results = api.lookup.rrset(owner_name: data, rrtype: "A") results.map do |result| first_seen = Time.at(result["time_first"]).to_date.to_s last_seen = Time.at(result["time_last"]).to_date.to_s values = result["rdata"] || [] values.map do |value| Record.new( data: value, first_seen: first_seen, last_seen: last_seen, source: name ) end end.flatten end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ukemi-0.4.1 | lib/ukemi/services/dnsdb.rb |