evennia.server.throttle¶
-
class
evennia.server.throttle.
Throttle
(**kwargs)[source]¶ Bases:
object
Keeps a running count of failed actions per IP address.
Available methods indicate whether or not the number of failures exceeds a particular threshold.
This version of the throttle is usable by both the terminal server as well as the web server, imposes limits on memory consumption by using deques with length limits instead of open-ended lists, and removes sparse keys when no recent failures have been recorded.
-
error_msg
= 'Too many failed attempts; you must wait a few minutes before trying again.'¶
-
__init__
(**kwargs)[source]¶ Allows setting of throttle parameters.
- Keyword Arguments
limit (int) – Max number of failures before imposing limiter
timeout (int) – number of timeout seconds after max number of tries has been reached.
cache_size (int) – Max number of attempts to record per IP within a rolling window; this is NOT the same as the limit after which the throttle is imposed!
-
get
(ip=None)[source]¶ Convenience function that returns the storage table, or part of.
- Parameters
ip (str, optional) – IP address of requestor
- Returns
storage (dict) –
- When no IP is provided, returns a dict of all
current IPs being tracked and the timestamps of their recent failures.
- timestamps (deque): When an IP is provided, returns a deque of
timestamps of recent failures only for that IP.
-