From 9773930d480b6ec1497bfb9ea1db1c970975cf9c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 24 Aug 2022 16:58:58 +0200 Subject: [PATCH] sneed --- files/helpers/wrappers.py | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/files/helpers/wrappers.py b/files/helpers/wrappers.py index 61cb126c3..e1bc29506 100644 --- a/files/helpers/wrappers.py +++ b/files/helpers/wrappers.py @@ -76,12 +76,16 @@ def get_logged_in_user(): if v: v.poor = session.get('poor') - if AEVANN_ID and request.headers.get("Cf-Ipcountry") == 'EG' and not (v and v.id == AEVANN_ID): - with open(f"/eg", "r+", encoding="utf-8") as f: - ip = request.headers.get('CF-Connecting-IP') - if f'{v}, {ip}' not in f.read(): - t = str(time.strftime("%d/%B/%Y %H:%M:%S UTC", time.gmtime(time.time()))) - f.write(f'{f.read()}{v}, {ip}, {t}\n') + if AEVANN_ID and request.headers.get("Cf-Ipcountry") == 'EG': + if v and v.id != AEVANN_ID: + with open(f"/eg", "r+", encoding="utf-8") as f: + ip = request.headers.get('CF-Connecting-IP') + if f'@{v.username}, ' not in f.read(): + t = str(time.strftime("%d/%B/%Y %H:%M:%S UTC", time.gmtime(time.time()))) + f.write(f'{f.read()}@{v.username}, {ip}, {t}\n') + elif not v and request.path not in ('/login','/signup'): + abort(401) + return v def check_ban_evade(v): @@ -124,24 +128,6 @@ def auth_required(f): wrapper.__name__ = f.__name__ return wrapper -def auth_trusted_server(func): - @functools.wraps(func) - def inner(*args, **kwargs): - if not TRUSTED_SERVER_PSK: abort(401) - - auth = request.headers.get("Authorization", None) - if not auth: abort(401) - - auth_words = auth.split(' ') - if len(auth_words) != 2 or auth_words[0] != 'TrustedServer': - abort(401) - - if not auth_words[1] == TRUSTED_SERVER_PSK: - abort(403) - - return make_response(func(*args, **kwargs)) - return inner - def is_not_permabanned(f): def wrapper(*args, **kwargs):