diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:01 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:01 +0100 |
commit | fd23821950f0562a8995735105cd31fdc6d55933 (patch) | |
tree | 967df2f5647803a6c46f4d52003b2231c1de72cb /lib/mauve/mauve_resolv.rb | |
parent | d3a3cfef9650b08f62db62bd7e86b673f9d77d0b (diff) |
* Rejigged configuration
* Added --test and --verbose flags for the server config
* Started proper test suite
* Config parsing now gives more sensible errors + backtrace
* Rejigged people and source lists
Diffstat (limited to 'lib/mauve/mauve_resolv.rb')
-rw-r--r-- | lib/mauve/mauve_resolv.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/mauve/mauve_resolv.rb b/lib/mauve/mauve_resolv.rb new file mode 100644 index 0000000..6c97bef --- /dev/null +++ b/lib/mauve/mauve_resolv.rb @@ -0,0 +1,35 @@ +require 'resolv-replace' + +# +# +# + +module Mauve + class MauveResolv + class << self + def get_ips_for(host) + record_types = %w(A AAAA) + ips = [] + + %w(A AAAA).each do |type| + begin + Resolv::DNS.open do |dns| + dns.getresources(host, Resolv::DNS::Resource::IN.const_get(type)).each do |a| + ips << a.address.to_s + end + end + rescue Resolv::ResolvError, Resolv::ResolvTimeout => e + logger.warn("#{host} could not be resolved because #{e.message}.") + end + end + ips + end + + def logger + @logger ||= Log4r::Logger.new(self.to_s) + end + end + end +end + + |