aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/mauve_resolv.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2012-03-22 17:31:27 +0000
committerPatrick J Cherry <patrick@bytemark.co.uk>2012-03-22 17:31:27 +0000
commit24554e44478fadb3c86dea76773d456c5284596d (patch)
tree817319e8d2f579a8f690d756d0fb62e74100ac30 /lib/mauve/mauve_resolv.rb
parent53c5b4412c46dd289eeac08a9a4768aaf9d069ff (diff)
Rejigged caching of alert_group, and the way source lists are searched, to
(hopefully) cut down on DNS resolving.
Diffstat (limited to 'lib/mauve/mauve_resolv.rb')
-rw-r--r--lib/mauve/mauve_resolv.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/mauve/mauve_resolv.rb b/lib/mauve/mauve_resolv.rb
index a9c7526..8ce8969 100644
--- a/lib/mauve/mauve_resolv.rb
+++ b/lib/mauve/mauve_resolv.rb
@@ -15,12 +15,10 @@ module Mauve
# @return [Array] Array of IP addresses, as Strings.
#
def get_ips_for(host)
- pp host
ips = []
- @count ||= 0
Resolv::DNS.open do |dns|
%w(A AAAA).each do |type|
- @count += 1
+ self.count += 1 if $debug
begin
ips += dns.getresources(host, Resolv::DNS::Resource::IN.const_get(type)).collect{|a| a.address.to_s}
rescue Resolv::ResolvError, Resolv::ResolvTimeout => e
@@ -35,6 +33,10 @@ module Mauve
@count ||= 0
end
+ def count=(c)
+ @count = c
+ end
+
# @return [Log4r::Logger]
def logger
@logger ||= Log4r::Logger.new(self.to_s)