Limit number of stored failures
Failures are messages shown on the access captcha screen when the captcha answer was not accepted for whatever reason.
このコミットが含まれているのは:
コミット
95a940a14f
|
@ -38,7 +38,7 @@ def create_app(toml_config):
|
|||
app.captcha_factory = create_captcha_factory(app.config['CAPTCHA_FONTS'])
|
||||
app.captcha_signer = create_captcha_signer(app.config['SECRET_KEY'])
|
||||
|
||||
app.failures = {}
|
||||
app.failures = OrderedDict()
|
||||
|
||||
# State for tasks
|
||||
app.users_update_buffer = set()
|
||||
|
|
|
@ -2,6 +2,7 @@ import time
|
|||
|
||||
from quart import current_app
|
||||
|
||||
CONFIG = current_app.config
|
||||
FAILURES = current_app.failures
|
||||
|
||||
def add_failure(message):
|
||||
|
@ -9,6 +10,10 @@ def add_failure(message):
|
|||
while timestamp in FAILURES:
|
||||
timestamp += 1
|
||||
FAILURES[timestamp] = message
|
||||
|
||||
while len(FAILURES) > CONFIG['MAX_FAILURES']:
|
||||
FAILURES.popitem(last=False)
|
||||
|
||||
return timestamp
|
||||
|
||||
def pop_failure(failure_id):
|
||||
|
|
|
@ -84,11 +84,13 @@ def toml_to_flask_section_names(config):
|
|||
def toml_to_flask_section_memory(config):
|
||||
cfg = config['memory']
|
||||
assert cfg['states'] >= 0
|
||||
assert cfg['failures'] >= 0
|
||||
assert cfg['chat_scrollback'] >= 0
|
||||
assert cfg['chat_messages'] >= cfg['chat_scrollback']
|
||||
return {
|
||||
'MAX_STATES': cfg['states'],
|
||||
'MAX_CAPTCHAS': cfg['captchas'],
|
||||
'MAX_FAILURES': cfg['failures'],
|
||||
'MAX_CHAT_MESSAGES': cfg['chat_messages'],
|
||||
'MAX_CHAT_SCROLLBACK': cfg['chat_scrollback'],
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ foreground_color = "#dddddd"
|
|||
[memory]
|
||||
states = 32
|
||||
captchas = 256
|
||||
failures = 256
|
||||
chat_messages = 8192
|
||||
chat_scrollback = 256
|
||||
|
||||
|
|
読み込み中…
新しいイシューから参照