class Jungler

Constants

IP_REGEX
NS_REGEX
VERSION

Attributes

domain[RW]

Public Class Methods

new(domain) click to toggle source
# File lib/jungler.rb, line 6
def initialize(domain)
  @domain = domain
end

Public Instance Methods

corresponding_ip() click to toggle source
# File lib/jungler.rb, line 16
def corresponding_ip
  packet = Net::DNS::Resolver.start(@domain)
  answer = packet.answer.join('')
  ips = answer.scan(IP_REGEX)
  ips.each do |ip|
    ip = ip.first
    puts "#{domain} is hosted on IP : #{ip}\n"
  end
  puts "-----------------------------------------"
end
ns_records() click to toggle source
# File lib/jungler.rb, line 27
def ns_records
  packet = Net::DNS::Resolver.start(domain, Net::DNS::NS)
  answer = packet.answer.join('')
  nss = answer.scan(NS_REGEX)
  i = 1
  nss.each do |ns|
    ns = ns.first
    puts "Name server #{i} for domain #{@domain} : #{ns}\n"
    i += 1
  end
  puts "-----------------------------------------"
end
ping_status() click to toggle source
# File lib/jungler.rb, line 40
def ping_status
  Net::Ping::TCP.service_check = true

  pt = Net::Ping::TCP.new(@domain)
  if pt.ping
    puts "#{@domain} is alive."
  else
    puts "#{@domain} seems to be dead or is not reachable."
  end
end
stalk() click to toggle source
# File lib/jungler.rb, line 10
def stalk
  corresponding_ip
  ns_records
  ping_status
end