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.
 
 
 
 
 
 
cryptcheck-rails/app/controllers/site_controller.rb

37 lines
787 B

require 'simpleidn'
class SiteController < ApplicationController
def check
host, port, type = params[:host], params[:port], params[:type]
host = SimpleIDN.to_ascii host.downcase
if host.blank? or /[^a-zA-Z0-9.-]/ =~ host
flash[:danger] = "Hôte #{host} invalide"
render :index
return
end
unless port.blank?
port = port.to_i
unless (1..65535).include? port
flash[:danger] = "Port #{port} invalide"
render :index
return
end
host = "#{host}:#{port}"
end
unless %w(https smtp xmpp tls ssh).include? type
flash[:danger] = "Type #{type} invalide"
render :index
return
end
redirect_to "/#{type}/#{host}"
end
def suite
@suite = params[:id] || params.require(:suite)
@ciphers = CryptCheck::Tls::Cipher.list @suite
end
end