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 949B

12345678910111213141516171819202122232425262728293031323334
  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)
  18. .sort_by(&:priority).first
  19. if srv
  20. hostname, port = srv.target.to_s, srv.port
  21. else # DNS is not correctly set, guess config…
  22. hostname = domain
  23. end
  24. self.analyze hostname, port, domain: domain, type: type
  25. end
  26. def self.analyze_file(input, output)
  27. ::CryptCheck.analyze_file(input, 'output/xmpp.erb', output) { |host| self.analyze_domain host }
  28. end
  29. end
  30. end
  31. end