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.

smtp.rb 642B

123456789101112131415161718192021
  1. module CryptCheck
  2. module Tls
  3. module Smtp
  4. def self.analyze(host, port=25, domain: nil)
  5. ::CryptCheck.analyze host, port, Server, Grade, domain: domain
  6. end
  7. def self.analyze_domain(domain)
  8. srv = Resolv::DNS.new.getresources(domain, Resolv::DNS::Resource::IN::MX).sort_by &:preference
  9. hosts = srv.empty? ? [domain] : srv.collect { |s| s.exchange.to_s }
  10. results = {}
  11. hosts.each { |h| results.merge! self.analyze(h, domain: domain) }
  12. results
  13. end
  14. def self.analyze_file(input, output)
  15. ::CryptCheck.analyze_file(input, 'output/smtp.erb', output) { |host| self.analyze_domain host }
  16. end
  17. end
  18. end
  19. end