From 24554e44478fadb3c86dea76773d456c5284596d Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Thu, 22 Mar 2012 17:31:27 +0000 Subject: Rejigged caching of alert_group, and the way source lists are searched, to (hopefully) cut down on DNS resolving. --- lib/mauve/mauve_resolv.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/mauve/mauve_resolv.rb') 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) -- cgit v1.2.1