%h1 Manually Banned IP Addresses
%table.table.table-striped
%thead
%tr
%th Key
%th Banned IP
%th Expires
%th Actions
= render partial: 'rack_attack_admin/banned_ips/banned_ip',
collection: Rack::Attack::BannedIps.keys, as: 'key',
locals: { _:nil,
full_key_prefix: Rack::Attack::BannedIps.full_key_prefix,
expires_column: true,
}
= form_for @default_banned_ip, url: [rack_attack_admin, :banned_ips] do |f|
%tr
%td Add new:
%td= f.text_field :ip
%td= f.text_field :bantime
%td= f.submit 'Ban', class: 'btn btn-danger'
%h1 Fail2Ban/Allow2Ban Bans
%table.table.table-striped
%thead
%tr
%th Key
%th Banned IP
- if has_ttl?
%th Expires
%th Actions
= render partial: 'rack_attack_admin/banned_ips/banned_ip',
collection: Rack::Attack::Fail2Ban.banned_ip_keys, as: 'key',
locals: { _:nil,
full_key_prefix: Rack::Attack::Fail2Ban.full_key_prefix,
}
%h1 Throttle/Fail2Ban Counters
%table.table.table-striped.mb-0
%thead
%tr
%th Type:Name
%th Discriminator
%th
Value
\/Limit
%th
Expires
(Time bucket)
%th Actions
- @counters_h.each do |key, value|
:ruby
parsed = Rack::Attack.parse_key(key)
value = value.to_i
name = Rack::Attack.humanize_key(key).sub(":#{parsed[:discriminator]}", '')
# We can get expires_in from redis or directly from the matched throttle rule
interval =
if has_ttl?
redis.ttl("#{Rack::Attack.prefix_with_namespace}:#{key}")
elsif parsed and time_range = parsed[:time_range]
(time_range.end - Time.now)
end
if parsed
time_range = parsed[:time_range]
end
if time_range
human_duration = time_range.duration&.human_str
end
%tr
%td
= name
-# if parsed and rule = parsed[:rule]
%code= rule.inspect_with_options
%td= parsed[:discriminator]
- limit = parsed && (rule = parsed[:rule]) && rule.limit.to_i
- over_limit = limit && value >= limit
%td{class: ('over_limit' if over_limit), style: ('color: red' if over_limit)}
= value
- if limit
Limit:
= "#{limit}"
= "/#{human_duration}" if human_duration
- if time_range
%small
(#{(limit / (time_range.duration/60.0)).round(0)}/min)
%td
- if interval
- if interval < 0
expired
- elsif interval
in #{ActiveSupport::Duration.build(interval)&.human_str}
- if time_range
%small
(#{ time_range.begin.to_s(:time_with_s)}
%span><
\-
#{time_range.end .to_s(:time_with_s)}
\= #{human_duration})
%td= link_to 'Delete', rack_attack_admin.key_path(key), method: :delete, class: 'btn'
.current_time.mb-2 (Current time: #{Time.now.to_s(:time_with_s)})