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.

35 lines
807B

  1. class CheckWorker
  2. include Sidekiq::Worker
  3. sidekiq_options retry: false
  4. def key_to_json(key)
  5. key.nil? ? nil : { type: key.type, size: key.size }
  6. end
  7. def perform(host, port=nil)
  8. host = SimpleIDN.to_ascii host.downcase
  9. result = self.analyze *(port ? [host, port] : [host])
  10. result = result.to_h
  11. result[:date] = DateTime.now
  12. Datastore.post self.type, host, port, result
  13. end
  14. protected
  15. def to_json(server)
  16. {
  17. key: key_to_json(server.key),
  18. dh: server.dh.collect { |k| key_to_json k },
  19. protocols: server.supported_protocols,
  20. ciphers: server.supported_ciphers.collect { |c| { protocol: c.protocol, name: c.name, size: c.size, dh: key_to_json(c.dh) } },
  21. }
  22. end
  23. private
  24. def grade_to_json(grade)
  25. {
  26. rank: grade.grade,
  27. }
  28. end
  29. end