class Socialinvestigator::Client::Net::DNS

Public Class Methods

new() click to toggle source
# File lib/socialinvestigator/client/net.rb, line 107
def initialize
  @resolv = Dnsruby::Resolver.new
end

Public Instance Methods

find_domain( hostname ) click to toggle source
# File lib/socialinvestigator/client/net.rb, line 111
def find_domain( hostname )
  # puts "Looking for SOA of #{hostname}"
  soa = @resolv.query( hostname, "SOA" ).answer.select do |rr|
    rr.is_a? Dnsruby::RR::IN::SOA
  end

  return hostname if soa.length > 0

  parts = hostname.split( /\./ )
  return nil if parts.length <= 2

  find_domain( parts.slice(1,100).join( "." ) )
end