class Rack::Attack::BannedIps
Public Class Methods
ban!(ip, bantime)
click to toggle source
# File lib/rack/attack_extensions.rb, line 346 def ban!(ip, bantime) cache.write("#{key_prefix}:#{ip}", 1, bantime) end
banned?(ip)
click to toggle source
# File lib/rack/attack_extensions.rb, line 350 def banned?(ip) cache.read("#{key_prefix}:#{ip}") ? true : false end
full_key_prefix()
click to toggle source
# File lib/rack/attack_extensions.rb, line 359 def full_key_prefix "#{cache.prefix}:#{key_prefix}" end
ip_from_key(key)
click to toggle source
# File lib/rack/attack_extensions.rb, line 354 def ip_from_key(key) key = Rack::Attack.unprefix_key(key) key.sub "#{key_prefix}:", '' end
ips()
click to toggle source
# File lib/rack/attack_extensions.rb, line 340 def ips prefixed_keys.map { |key| ip_from_key(key) } end
keys()
click to toggle source
Removes only the Rack::Attack.cache.prefix
# File lib/rack/attack_extensions.rb, line 334 def keys prefixed_keys.map { |key| Rack::Attack.unprefix_key(key) } end
prefixed_keys()
click to toggle source
# File lib/rack/attack_extensions.rb, line 329 def prefixed_keys Rack::Attack.all_keys.grep(/^#{full_key_prefix}:/) end
Protected Class Methods
key_prefix()
click to toggle source
# File lib/rack/attack_extensions.rb, line 365 def key_prefix 'banned_ips' end
Private Class Methods
cache()
click to toggle source
# File lib/rack/attack_extensions.rb, line 371 def cache Rack::Attack.cache end