mirror of
https://git.wownero.com/wownero/wownero-funding-system.git
synced 2024-08-15 00:53:45 +00:00
Actually make throttling work correctly
This commit is contained in:
parent
3989dbdf8c
commit
523fa1c569
1 changed files with 11 additions and 8 deletions
|
@ -46,16 +46,19 @@ def api_qr_generate(address):
|
||||||
"""
|
"""
|
||||||
from funding.factory import cache
|
from funding.factory import cache
|
||||||
|
|
||||||
throttling_seconds = 3
|
qr = QrCodeGenerator()
|
||||||
|
if not qr.exists(address):
|
||||||
|
# create a new QR code
|
||||||
ip = get_ip()
|
ip = get_ip()
|
||||||
cache_key = 'qr_ip_%s' % ip
|
cache_key = 'qr_ip_%s' % ip
|
||||||
hit = cache.get(cache_key)
|
hit = cache.get(cache_key)
|
||||||
|
|
||||||
if hit and ip not in ['127.0.0.1', 'localhost']:
|
if hit and ip not in ['127.0.0.1', 'localhost']:
|
||||||
return Response('Wait a bit before generating a new QR', 403)
|
return Response('Wait a bit before generating a new QR', 403)
|
||||||
cache.set(cache_key, {}, throttling_seconds)
|
|
||||||
|
|
||||||
qr = QrCodeGenerator()
|
throttling_seconds = 3
|
||||||
if not qr.exists(address):
|
cache.set(cache_key, {'wow': 'kek'}, throttling_seconds)
|
||||||
|
|
||||||
created = qr.create(address)
|
created = qr.create(address)
|
||||||
if not created:
|
if not created:
|
||||||
raise Exception('Could not create QR code')
|
raise Exception('Could not create QR code')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue