Class: Naminori::Service::Dns

Inherits:
Base
  • Object
show all
Defined in:
lib/naminori/service/dns.rb

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

event, event_ip, #initialize

Constructor Details

This class inherits a constructor from Naminori::Service::Base

Instance Method Details

#default_configObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/naminori/service/dns.rb', line 16

def default_config
  {
    role:      "dns",
    port:      "53",
    protocols: ["udp", "tcp"],
    vip:       "192.168.77.9",
    method:    "nat",
    query:     "pepabo.com",
    retry:     3,
    timeout:   3,
    notifier:  nil
  }
end

#healty?(ip) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
# File 'lib/naminori/service/dns.rb', line 6

def healty?(ip)
  dns = Resolv::DNS.new(:nameserver => ip )
  dns.timeouts = config.timeout
  begin
    dns.getaddress(@config.query)
  rescue => e
    false
  end
end