Module: DNSCheck::Node

Extended by:
Core, Node
Included in:
Node
Defined in:
lib/dns-check/node.rb

Instance Method Summary collapse

Methods included from Core

__init

Instance Method Details

#hostnameObject



21
22
23
# File 'lib/dns-check/node.rb', line 21

def hostname
  DNSCheck.config[:hostname]
end

#outputObject



29
30
31
# File 'lib/dns-check/node.rb', line 29

def output
  output ||= Output.new
end

#resolvObject



17
18
19
# File 'lib/dns-check/node.rb', line 17

def resolv
  DNSCheck
end

#resolv_allObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/dns-check/node.rb', line 33

def resolv_all
  resolv.timeout = timeout

  EM.run do
    Fiber.new do
      @records.each do |e, ns, c|
        resolv.nameservers = ns

        resolved_ip = resolv.lookup(hostname)
        output_msg = [e, resolved_ip, ns.sample, c]
        output.insert do
          output.print_msg output_msg
        end
      end
      EM.stop
    end.resume
  end
end

#startObject



12
13
14
15
# File 'lib/dns-check/node.rb', line 12

def start
  @records = __init(DNSCheck.config)
  resolv_all
end

#timeoutObject



25
26
27
# File 'lib/dns-check/node.rb', line 25

def timeout
  DNSCheck.config[:timeout]
end