Class: Netchk::DNSResolvVerifier

Inherits:
Object
  • Object
show all
Defined in:
lib/netchk/dns_resolv_verifier.rb

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ DNSResolvVerifier

Returns a new instance of DNSResolvVerifier.



4
5
6
7
# File 'lib/netchk/dns_resolv_verifier.rb', line 4

def initialize(**options)
  @domains = options['domains'] || %w[google.com youtube.com facebook.com]
  @resolv_conf = options['resolv.conf']
end

Instance Method Details

#verifyObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/netchk/dns_resolv_verifier.rb', line 9

def verify
  ::Resolv::DNS.open(@resolv_conf) do |dns|
    @domains.each do |domain|
      begin
        dns.getaddress(domain)
      rescue ::Resolv::ResolvError
        $stderr.puts "Failed to resolve #{domain}"
      end
    end
  end
end