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.

xmpp.rb 911B

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