12 changed files with 72 additions and 69 deletions
@ -1,14 +1,19 @@ |
|||
class XmppController < CheckController |
|||
protected |
|||
def type |
|||
:xmpp |
|||
end |
|||
|
|||
def worker |
|||
XMPPWorker |
|||
end |
|||
|
|||
def tls_type |
|||
'STARTTLS' |
|||
end |
|||
protected |
|||
|
|||
def type |
|||
:xmpp |
|||
end |
|||
|
|||
def worker |
|||
XMPPWorker |
|||
end |
|||
|
|||
def tls_type |
|||
'STARTTLS' |
|||
end |
|||
|
|||
def default_args |
|||
:c2s |
|||
end |
|||
end |
|||
|
@ -1,11 +1,11 @@ |
|||
class CheckWorker |
|||
include Sidekiq::Worker |
|||
sidekiq_options retry: false |
|||
include Sidekiq::Worker |
|||
sidekiq_options retry: false |
|||
|
|||
def perform(host, port) |
|||
# analysis = Analysis.pending self.type, host, port |
|||
host = SimpleIDN.to_ascii host.downcase |
|||
result = self.analyze host, port |
|||
Analysis.post! self.type, host, port, result |
|||
end |
|||
def perform(host, *args) |
|||
host = SimpleIDN.to_ascii host.downcase |
|||
result = self.analyze host, *args |
|||
args = nil if args.empty? |
|||
Analysis.post! self.type, host, args, result |
|||
end |
|||
end |
|||
|
@ -1,12 +1,12 @@ |
|||
class HTTPSWorker < CheckWorker |
|||
sidekiq_options retry: false |
|||
sidekiq_options retry: false |
|||
|
|||
protected |
|||
def analyze(host, port=443) |
|||
CryptCheck::Tls::Https.analyze host, port |
|||
end |
|||
protected |
|||
def analyze(host, port) |
|||
CryptCheck::Tls::Https.analyze host, port |
|||
end |
|||
|
|||
def type |
|||
:https |
|||
end |
|||
def type |
|||
:https |
|||
end |
|||
end |
|||
|
@ -0,0 +1,15 @@ |
|||
class ConvertToArgs < ActiveRecord::Migration[5.2] |
|||
def self.up |
|||
add_column :analyses, :args, :jsonb, after: :host |
|||
Analysis.all.each { |a| a.update! args: { port: a.port }.compact } |
|||
add_index :analyses, %i[service host args], unique: true |
|||
remove_column :analyses, :port |
|||
end |
|||
|
|||
def self.down |
|||
add_column :analyses, :port, :integer |
|||
Analysis.all.each { |a| a.update! port: a.args } |
|||
remove_column :analyses, :args |
|||
add_index :analyses, %i[service host port], unique: true |
|||
end |
|||
end |
Loading…
Reference in new issue