Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Add an option to disable rate limiting. For testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-d authored and chromakode committed Oct 7, 2011
1 parent e853b92 commit 1ecb427
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions r2/example.ini
Expand Up @@ -46,6 +46,7 @@ INDEXTANK_API_URL =
# -- feature toggles --
disable_ads = false
disable_captcha = false
disable_ratelimit = false

# -- important settings --
# the domain that this app serves itself up as
Expand Down
4 changes: 4 additions & 0 deletions r2/r2/controllers/validator/validator.py
Expand Up @@ -1091,6 +1091,8 @@ def __init__(self, rate_user = False, rate_ip = False,
Validator.__init__(self, *a, **kw)

def run (self):
if g.disable_ratelimit:
return
to_check = []
if self.rate_user and c.user_is_loggedin:
to_check.append('user' + str(c.user._id36))
Expand Down Expand Up @@ -1131,6 +1133,8 @@ def __init__(self, category, *a, **kw):
Validator.__init__(self, *a, **kw)

def run (self):
if g.disable_ratelimit:
return
key = "VDelay-%s-%s" % (self.category, request.ip)
prev_violations = g.cache.get(key)
if prev_violations:
Expand Down
1 change: 1 addition & 0 deletions r2/r2/lib/app_globals.py
Expand Up @@ -85,6 +85,7 @@ class Globals(object):
'db_create_tables',
'disallow_db_writes',
'exception_logging',
'disable_ratelimit',
'amqp_logging',
'read_only_mode',
'frontpage_dart',
Expand Down

0 comments on commit 1ecb427

Please sign in to comment.