mirror of
https://github.com/SrIzan10/hc-harbor.git
synced 2026-05-01 10:45:21 +00:00
better handling of messups
This commit is contained in:
@@ -8,14 +8,17 @@ class Rack::Attack
|
||||
|
||||
if ENV["RACK_ATTACK_BYPASS"].present?
|
||||
begin
|
||||
TOKENS = JSON.parse(ENV["RACK_ATTACK_BYPASS"]).freeze
|
||||
bypass_value = ENV["RACK_ATTACK_BYPASS"].strip
|
||||
bypass_value = bypass_value.gsub(/\A['"]|['"]\z/, "")
|
||||
|
||||
TOKENS = JSON.parse(bypass_value).freeze
|
||||
unless TOKENS.is_a?(Array)
|
||||
Rails.logger.warn "RACK_ATTACK_BYPASS should be a array, tf is this #{TOKENS.class}"
|
||||
TOKENS = [].freeze
|
||||
end
|
||||
Rails.logger.info "RACK_ATTACK_BYPASS loaded #{TOKENS.length} let me in tokens"
|
||||
rescue JSON::ParserError => e
|
||||
Rails.logger.error "RACK_ATTACK_BYPASS failed to read, you fucked it up #{e.message}"
|
||||
Rails.logger.error "RACK_ATTACK_BYPASS failed to read, you fucked it up #{e.message} raw: #{ENV['RACK_ATTACK_BYPASS'].inspect}"
|
||||
TOKENS = [].freeze
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user