add automatic DDOS mitigation

pull/139/head
Aevann 2023-03-11 08:13:58 +02:00
parent 99d12c6fac
commit 04844fc7ce
5 changed files with 26 additions and 2 deletions

View File

@ -204,6 +204,7 @@
.fa-lock:before{content:"\f023"}
.fa-lock-open:before{content:"\f3c1"}
.fa-down:before{content:"\f354"}
.fa-shield-virus:before{content:"\e06c"}
button {
background: none;

View File

@ -96,6 +96,11 @@ 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',
@ -161,6 +166,11 @@ 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',
@ -409,4 +419,5 @@ AEVANN_MODACTION_TYPES = {'ban_user','unban_user',
'shadowban','unshadowban',
'progstack_post','progstack_comment',
'unprogstack_post', 'unprogstack_comment',
'delete_media'}
'delete_media',
'enable_automatic_DDOS_mitigation', 'disable_automatic_DDOS_mitigation'}

View File

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

View File

@ -12,7 +12,7 @@ from files.classes.user import User
from files.helpers.assetcache import assetcache_path
from files.helpers.config.const import *
from files.helpers.regex import *
from files.helpers.settings import get_settings, get_setting
from files.helpers.settings import *
from files.helpers.sorting_and_time import make_age_string
from files.routes.routehelpers import get_alt_graph, get_formkey
from files.__main__ import app, cache
@ -75,6 +75,16 @@ def calc_users():
cache.set(LOGGED_OUT_CACHE_KEY, loggedout)
loggedin_counter = len(loggedin)
loggedout_counter = len(loggedout)
if get_setting('automatic_DDOS_mitigation'):
if loggedout_counter > loggedin_counter:
if not get_setting('login_required'):
toggle_setting('login_required')
else:
if get_setting('login_required'):
toggle_setting('login_required')
return {'loggedin_counter':loggedin_counter,
'loggedout_counter':loggedout_counter,
'loggedin_chat':loggedin_chat}

View File

@ -0,0 +1 @@
alter table modactions alter column kind type varchar(33);