Try putting something like this in your controller to detect and ban IP
addresses that download too fast:
# block malicious crawlers that download too fast
BAN_IP_TIME = 60 * 60 * 24 # 1 day
ban_key = request.client + 'ban'
if cache.ram(ban_key, lambda: False, BAN_IP_TIME):
raise HTTP(500, 'IP blocked')
# maximum number of fast requests allowed before banned
MAX_REQUESTS = 10
request_key = request.client + 'requests'
cache.ram(request_key, lambda: 0, 1)
if cache.ram.increment(request_key) > MAX_REQUESTS:
cache.ram(ban_key,
lambda: True, BAN_IP_TIME)
redirect(URL(f='index'))
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.