Class: Socialinvestigator::Client::Net::DNS
- Inherits:
-
Object
- Object
- Socialinvestigator::Client::Net::DNS
- Defined in:
- lib/socialinvestigator/client/net.rb
Instance Method Summary collapse
- #find_domain(hostname) ⇒ Object
-
#initialize ⇒ DNS
constructor
A new instance of DNS.
Constructor Details
#initialize ⇒ DNS
Returns a new instance of DNS.
107 108 109 |
# File 'lib/socialinvestigator/client/net.rb', line 107 def initialize @resolv = Dnsruby::Resolver.new end |
Instance Method Details
#find_domain(hostname) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 |
# 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 |