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/sender.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/sender.rb')
-rw-r--r-- | lib/mauve/sender.rb | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/lib/mauve/sender.rb b/lib/mauve/sender.rb index ad047fe..8194180 100644 --- a/lib/mauve/sender.rb +++ b/lib/mauve/sender.rb @@ -1,7 +1,7 @@ # encoding: UTF-8 require 'ipaddr' -require 'resolv' require 'socket' +require 'mauve/mauve_resolv' require 'mauve/mauve_time' module Mauve @@ -56,6 +56,7 @@ module Mauve use_srv = false end + list = [] Resolv::DNS.open do |dns| if use_srv # @@ -64,37 +65,29 @@ module Mauve # srv_domain = (domain[0] == ?_ ? domain : "_mauvealert._udp.#{domain}") - list = dns.getresources(srv_domain, SRV).map do |srv| + list += dns.getresources(srv_domain, SRV).map do |srv| [srv.target.to_s, srv.port] end end + end + # + # If nothing found, just use the domain and port + # + list = [[domain, port]] if list.empty? + list.each do |d,p| + r = [] # - # If nothing found, just use the domain and port + # This gets both AAAA and A records # - list = [[domain, port]] if list.empty? - - list.each do |d,p| - r = [] - # - # Try IPv6 first. - # - dns.getresources(d, AAAA).map do |a| - r << [a.address.to_s, p] - end - - # - # Try IPv4 too. - # - dns.getresources(d, A).each do |a| - r << [a.address.to_s, p] - end - - results += r unless r.empty? + Mauve::MauveResolv.get_ips_for(d).each do |a| + r << [a, p] end - end - end - end + + results += r unless r.empty? + end + end ## case + end ## each # # Validate results. |