mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +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)
|
||||
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}"
|
||||
do_count(key, expires_in)
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue