better DDOS mitigation

master
Aevann 2023-04-08 23:34:16 +02:00
parent 817defda85
commit bb11bf899e
3 changed files with 16 additions and 29 deletions

View File

@ -101,11 +101,6 @@ MODACTION_TYPES = {
"icon": 'fa-images',
"color": 'bg-muted'
},
'disable_automatic_DDOS_mitigation': {
"str": 'disabled automatic DDOS mitigation',
"icon": 'fa-shield-virus',
"color": 'bg-danger'
},
'distinguish_comment': {
"str": 'distinguished {self.target_link}',
"icon": 'fa-crown',
@ -176,11 +171,6 @@ MODACTION_TYPES = {
"icon": 'fa-images',
"color": 'bg-success',
},
'enable_automatic_DDOS_mitigation': {
"str": 'enabled automatic DDOS mitigation',
"icon": 'fa-shield-virus',
"color": 'bg-success',
},
'flair_post': {
"str": 'set a flair on {self.target_link}',
"icon": 'fa-tag',
@ -429,5 +419,4 @@ MODACTION_TYPES__FILTERED = deepcopy({t:v for t,v in MODACTION_TYPES.items()
if not t in MODACTION_PRIVILEGED__TYPES})
AEVANN_MODACTION_TYPES = {'ban_user','unban_user',
'shadowban','unshadowban',
'delete_media',
'enable_automatic_DDOS_mitigation', 'disable_automatic_DDOS_mitigation'}
'delete_media'}

View File

@ -15,8 +15,7 @@ _SETTINGS = {
"login_required": False,
"under_siege": False,
"dm_images": True,
"under_attack": False,
"automatic_DDOS_mitigation": True,
"under_attack": False
}
def get_setting(setting:str):

View File

@ -77,22 +77,21 @@ def calc_users():
loggedin_counter = len(loggedin)
loggedout_counter = len(loggedout)
if get_setting('automatic_DDOS_mitigation'):
if SITE == 'watchpeopledie.tv': mul = 5
else: mul = 1
if SITE == 'watchpeopledie.tv': mul = 3
else: mul = 1
if loggedout_counter > (loggedin_counter * mul):
if not get_setting('login_required'):
toggle_setting('login_required')
if not get_setting('under_attack'):
toggle_setting('under_attack')
set_security_level('under_attack')
else:
if get_setting('login_required'):
toggle_setting('login_required')
if get_setting('under_attack'):
toggle_setting('under_attack')
set_security_level('high')
if loggedout_counter > (loggedin_counter * mul):
if not get_setting('login_required'):
toggle_setting('login_required')
if not get_setting('under_attack'):
toggle_setting('under_attack')
set_security_level('under_attack')
else:
if get_setting('login_required'):
toggle_setting('login_required')
if get_setting('under_attack'):
toggle_setting('under_attack')
set_security_level('high')
return {'loggedin_counter':loggedin_counter,