Skip to content

Commit

Permalink
Merge branches 'max_generation' and 'ratelimitfile' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Mar 15, 2024
2 parents 4f6f274 + ddaa49e commit f882bb8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mapit/ratelimitcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
}
_sentinel = object()

CONFIG_FILE = getattr(settings, 'MAPIT_RATE_LIMIT_FILE', {})
if isinstance(CONFIG_FILE, dict) and CONFIG_FILE.get('internal_ips'):
CONFIG['ips'] += CONFIG_FILE['internal_ips']['ipv4']
CONFIG['ips'] += CONFIG_FILE['internal_ips']['ipv6']


def ratelimit(_f=_sentinel, **kwargs):
if _f is _sentinel:
Expand Down
8 changes: 8 additions & 0 deletions project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
# excluded from rate limiting. Optional.
MAPIT_RATE_LIMIT = config.get('RATE_LIMIT', {})

MAPIT_RATE_LIMIT_FILE = config.get('RATE_LIMIT_FILE')
if MAPIT_RATE_LIMIT_FILE:
try:
with open(MAPIT_RATE_LIMIT_FILE, 'r') as fp:
MAPIT_RATE_LIMIT_FILE = yaml.load(fp, Loader=yaml.SafeLoader)
except:
MAPIT_RATE_LIMIT_FILE = None

# A GA code for analytics
GOOGLE_ANALYTICS = config.get('GOOGLE_ANALYTICS', '')

Expand Down

0 comments on commit f882bb8

Please sign in to comment.