mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: optional default off global per ip rate limiter
This commit is contained in:
parent
3c230d8f97
commit
4986ebcf24
4 changed files with 132 additions and 1 deletions
|
@ -28,6 +28,12 @@ class RateLimiter
|
|||
$redis.delete_prefixed(RateLimiter.key_prefix)
|
||||
end
|
||||
|
||||
def self.clear_all_global!
|
||||
$redis.without_namespace.keys("GLOBAL::#{key_prefix}*").each do |k|
|
||||
$redis.without_namespace.del k
|
||||
end
|
||||
end
|
||||
|
||||
def build_key(type)
|
||||
"#{RateLimiter.key_prefix}:#{@user && @user.id}:#{type}"
|
||||
end
|
||||
|
@ -38,7 +44,7 @@ class RateLimiter
|
|||
@key = build_key(type)
|
||||
@max = max
|
||||
@secs = secs
|
||||
@global = false
|
||||
@global = global
|
||||
end
|
||||
|
||||
def clear!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue