Module: DNSResolver::Config

Extended by:
Config
Included in:
Config, Resolver
Defined in:
lib/dnsresolver/config.rb

Constant Summary collapse

DEFAULTS =
{
  :nameservers => %w(8.8.8.8 8.8.4.4),
  :registry_name => 'dnsresolver'
}
DNSRUBY_DEFAULTS =
{
  :query_timeout => 2,
  :do_caching => true,
  :dnssec => true,
  :recurse => true,
  :port => 53,
  :use_tcp => false,
  :tsig => nil,
  :ignore_truncation => false,
  :src_address => nil,
  :src_port => 0,
  :udp_size => 4096,
  :retry_times => 1,
  :retry_delay => 5,
  :packet_timeout => 5
}

Instance Method Summary collapse

Instance Method Details

#dnsruby_settingsObject



43
44
45
# File 'lib/dnsresolver/config.rb', line 43

def dnsruby_settings
  @settings && @settings[:dnsruby] ? DNSRUBY_DEFAULTS.merge(@settings[:dnsruby]) : DNSRUBY_DEFAULTS
end

#load!(path) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dnsresolver/config.rb', line 27

def load!(path)
  if path.kind_of?(IO)
    file = path
  else
    file = File.open path
  end

  settings = YAML.load(file)
  load_configuration(settings) if settings.present?
  settings
end

#load_configuration(settings) ⇒ Object



39
40
41
# File 'lib/dnsresolver/config.rb', line 39

def load_configuration(settings)
  @settings = settings.with_indifferent_access
end

#settingsObject



47
48
49
# File 'lib/dnsresolver/config.rb', line 47

def settings
  @settings ? DEFAULTS.merge(@settings) : DEFAULTS
end