Skip to content

Commit

Permalink
Blocklist each ip separately
Browse files Browse the repository at this point in the history
  • Loading branch information
tramuntanal committed Jan 30, 2024
1 parent ae483eb commit bc87c62
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions config/initializers/rack_attack.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

unless %w(development test).include? Rails.env
# unless false && %w(development test).include? Rails.env
require "rack/attack"

limit= ENV["RACK_ATTACK_THROTTLE_LIMIT"] || 30
Expand All @@ -22,8 +22,12 @@
end
end

Rack::Attack.blocklist_ip(ENV["RACK_ATTACK_BLOCKED_IPS"].split(",")) if ENV["RACK_ATTACK_BLOCKED_IPS"].present?
end
if ENV["RACK_ATTACK_BLOCKED_IPS"].present?
ENV["RACK_ATTACK_BLOCKED_IPS"].split(",").each do |ip_or_subnet|
Rack::Attack.blocklist_ip(ip_or_subnet)
end
end
# end

__END__
headers= []
Expand Down

0 comments on commit bc87c62

Please sign in to comment.