You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cryptcheck/lib/cryptcheck/tls/smtp.rb

20 lines
407 B

6 years ago
require 'resolv'
8 years ago
module CryptCheck
module Tls
module Smtp
6 years ago
def self.analyze(hostname, port = 25)
srv = ::Resolv::DNS.new.getresources(hostname, ::Resolv::DNS::Resource::IN::MX)
.sort_by &:preference
hosts = if srv.empty?
[hostname]
else
srv.collect { |s| s.exchange.to_s }
end
6 years ago
Tls.aggregate hosts.collect { |h| Host.new h, port }
8 years ago
end
end
end
end