more permissive ratelimits, never ratelimit broadcaster

このコミットが含まれているのは:
n9k 2021-07-09 15:16:05 +00:00
コミット 6a256fe796
2個のファイルの変更9行の追加6行の削除

ファイルの表示

@ -108,19 +108,22 @@ def _comment(text, token, c_response, c_ciphertext, nonce):
if viewers[token]['banned']:
return N_BANNED
# check that the commenter hasn't acidentally sent the same request twice
# check that the commenter hasn't accidentally sent the same request twice
remove_expired_nonces()
try:
nonces.pop(nonce)
except KeyError:
return N_CONFIRM
if secrets.randbelow(50) == 0:
# don't ratelimit the broadcaster
if viewers[token]['broadcaster']:
pass
elif secrets.randbelow(50) == 0:
viewers[token]['verified'] = False
return N_CAPTCHA_RANDOM
if now < viewers[token]['last_comment'] + CHAT_TIMEOUT:
elif now < viewers[token]['last_comment'] + CHAT_TIMEOUT:
return N_TOOFAST
if len(viewers[token]['recent_comments']) + 1 >= FLOOD_THRESHOLD:
elif len(viewers[token]['recent_comments']) + 1 >= FLOOD_THRESHOLD:
viewers[token]['verified'] = False
return N_FLOOD

ファイルの表示

@ -23,9 +23,9 @@ with open(CONFIG_FILE) as fp:
# TODO: always read hls_time from stream.m3u8
VIEW_COUNTING_PERIOD = 30 # count views from the last x seconds
CHAT_TIMEOUT = 5 # seconds between chat messages
CHAT_TIMEOUT = 3 # seconds between chat messages
FLOOD_PERIOD = 20 # seconds
FLOOD_THRESHOLD = 3 # messages in FLOOD_PERIOD seconds
FLOOD_THRESHOLD = 4 # messages in FLOOD_PERIOD seconds
HOST_DEFAULT_NICKNAME = 'Broadcaster'
ANON_DEFAULT_NICKNAME = 'Anonymous'