Sha256: a382b491b1921cc4bc637bf3e894ca154bc8b2dedebc185de9df120f988d626d
Contents?: true
Size: 1.21 KB
Versions: 3
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true require "net/https" module Mihari module Enrichers class GooglePublicDNS < Base # # Query Google Public DNS # # @param [String] name # # @return [Array<Mihari::Structs::Shodan::GooglePublicDNS::Response>] # def query(name) %w[A AAAA CNAME TXT NS].filter_map do |resource_type| query_by_type(name, resource_type) end end # # Query Google Public DNS by resource type # # @param [String] name # @param [String] resource_type # # @return [Mihari::Structs::Shodan::GooglePublicDNS::Response, nil] # def query_by_type(name, resource_type) url = "https://dns.google/resolve" params = { name: name, type: resource_type } res = http.get(url, params: params) data = JSON.parse(res.body.to_s) Structs::GooglePublicDNS::Response.from_dynamic! data rescue HTTPError nil end class << self # # @return [String] # def class_key "google_public_dns" end end private def http HTTP::Factory.build timeout: timeout end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mihari-5.6.2 | lib/mihari/enrichers/google_public_dns.rb |
mihari-5.6.1 | lib/mihari/enrichers/google_public_dns.rb |
mihari-5.6.0 | lib/mihari/enrichers/google_public_dns.rb |