Module: Tuktuk::DNS
- Defined in:
- lib/tuktuk/dns.rb
Class Method Summary collapse
- .get_mx(host) ⇒ Object
- .get_using_net_dns(host) ⇒ Object
- .get_using_resolve(host) ⇒ Object
- .sort_mx(res) ⇒ Object
Class Method Details
.get_mx(host) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/tuktuk/dns.rb', line 13 def get_mx(host) if defined?(Resolv::DNS) get_using_resolve(host) else get_using_net_dns(host) end end |
.get_using_net_dns(host) ⇒ Object
29 30 31 32 33 |
# File 'lib/tuktuk/dns.rb', line 29 def get_using_net_dns(host) if res = Net::DNS::Resolver.new.mx(host) sort_mx(res) end end |
.get_using_resolve(host) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/tuktuk/dns.rb', line 21 def get_using_resolve(host) Resolv::DNS.open do |dns| if res = dns.getresources(host, Resolv::DNS::Resource::IN::MX) sort_mx(res) end end end |
.sort_mx(res) ⇒ Object
35 36 37 |
# File 'lib/tuktuk/dns.rb', line 35 def sort_mx(res) res.sort {|x,y| x.preference <=> y.preference}.map { |rr| rr.exchange.to_s } end |