Sha256: fcf251838f055983d70499b6153b3dd0980b061afbe441f5f5d9d248fad90aae

Contents?: true

Size: 922 Bytes

Versions: 1

Compression:

Stored size: 922 Bytes

Contents

require 'dnsruby'

module Dnsmadeeasy_verify

  class Domain
    include Dnsruby

    attr_accessor :id, :name

    def initialize(id, name)
      @id = id
      @name = name
    end

    def available
      @whois ||= Whois.whois(@name)
      @whois.available?
    end

    def registered
      @whois ||= Whois.whois(@name)
      @whois.registered?
    end

    def do_name_servers_contain(domain)
      name_servers = get_name_servers
      return name_servers.any?{ |s| s.downcase().include?(domain) }
    end

    def get_name_servers
      ns = []
      res = Dnsruby::Resolver.new
      ns_req = nil
      begin
        ns_req = res.query(@name, "NS")
      rescue Exception => e
        return []
      end
      if (ns_req.header.ancount == 0)
        return []
      end

      (ns_req.answer.select {|r| r.type == "NS"}).each do |nsrr|
        ns << nsrr.domainname.to_s
      end

      ns
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dnsmadeeasy_verify-0.0.5 lib/dnsmadeeasy_verify/domain.rb