Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

67 Zeilen
1.4KB

  1. #!/usr/bin/env ruby
  2. require 'erb'
  3. require 'yaml'
  4. require 'thread'
  5. require 'parallel'
  6. require 'logging'
  7. $:.unshift 'lib'
  8. require 'sslcheck'
  9. #Logging.logger.root.appenders = Logging.appenders.stdout
  10. #Logging.logger.root.level = :info
  11. SCORES = %w(A+ A A- B C D E F T M)
  12. def score(a); SCORES.index a.grade; end
  13. def check(hostname)
  14. hostname.strip!
  15. #print ' ', hostname, ' : '
  16. begin
  17. server = SSLCheck::Server.new hostname
  18. note = SSLCheck::Grade.new server
  19. #puts note.grade
  20. note
  21. rescue => e
  22. puts e
  23. raise
  24. end
  25. end
  26. config = YAML.load_file 'hosts.yml'
  27. results = Hash[config.collect { |c| [c['description'], []] }]
  28. tests = []
  29. config.each do |c|
  30. description, hosts = c['description'], c['hostnames']
  31. hosts.each { |host| tests << [description, host] }
  32. end
  33. # tests.each do |description, host|
  34. # results[description] << check(host)
  35. # end
  36. semaphore = Mutex.new
  37. Parallel.each tests, progress: 'Testing', in_threads: 8 do |description, host|
  38. begin
  39. result = check host
  40. semaphore.synchronize do
  41. results[description] << result
  42. end
  43. rescue SSLCheck::Server::TLSNotAvailableException
  44. rescue Exception => e
  45. p host, e
  46. raise
  47. end
  48. end
  49. results.each do |d, _|
  50. results[d].sort! do |a, b|
  51. cmp = score(a) <=> score(b)
  52. cmp != 0 ? cmp : a.server.hostname <=> b.server.hostname
  53. end
  54. end
  55. puts 'Generate results'
  56. File.write 'output/index.html', ERB.new(File.read('index2.erb')).result(binding)