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.

32 lines
945B

  1. require 'erb'
  2. require 'parallel'
  3. module CryptCheck
  4. module Tls
  5. module Xmpp
  6. def self.analyze(host, port=nil, domain: nil, type: :s2s)
  7. domain ||= host
  8. ::CryptCheck.analyze host, port, Server, Grade, domain: domain, type: type
  9. end
  10. def self.analyze_domain(domain, type: :s2s)
  11. service, port = case type
  12. when :s2s
  13. ['_xmpp-server', 5269]
  14. when :c2s
  15. ['_xmpp-client', 5222]
  16. end
  17. srv = Resolv::DNS.new.getresources("#{service}._tcp.#{domain}", Resolv::DNS::Resource::IN::SRV).sort_by &:priority
  18. hosts = srv.empty? ? [[domain, port]] : srv.collect { |s| [s.target.to_s, s.port] }
  19. results = {}
  20. hosts.each { |host, port| results.merge! self.analyze(host, port, domain: domain, type: type) }
  21. results
  22. end
  23. def self.analyze_file(input, output)
  24. ::CryptCheck.analyze_file(input, 'output/xmpp.erb', output) { |host| self.analyze_domain host }
  25. end
  26. end
  27. end
  28. end