mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-04-26 14:57:47 +00:00
Merge pull request #85 from kickstarter/69-spec-failures
Add 1 second buffer to expiry to correct throttles
This commit is contained in:
commit
8d3e824068
1 changed files with 2 additions and 1 deletions
|
|
@ -16,7 +16,8 @@ module Rack
|
||||||
|
|
||||||
def count(unprefixed_key, period)
|
def count(unprefixed_key, period)
|
||||||
epoch_time = Time.now.to_i
|
epoch_time = Time.now.to_i
|
||||||
expires_in = period - (epoch_time % period)
|
# Add 1 to expires_in to avoid timing error: http://git.io/i1PHXA
|
||||||
|
expires_in = period - (epoch_time % period) + 1
|
||||||
key = "#{prefix}:#{(epoch_time/period).to_i}:#{unprefixed_key}"
|
key = "#{prefix}:#{(epoch_time/period).to_i}:#{unprefixed_key}"
|
||||||
do_count(key, expires_in)
|
do_count(key, expires_in)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue