From 3d54f95a01cffdfdfadd989c42db7e6f8c1af7f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Tue, 13 May 2025 07:57:56 +0200 Subject: [PATCH] zmiany w acl --- app.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/app.py b/app.py index 8437997..a03edc1 100644 --- a/app.py +++ b/app.py @@ -63,22 +63,20 @@ def load_user(user_id): return User.query.get(int(user_id)) def get_real_ip(): - - if "CF-Connecting-IP" in request.headers: - return request.headers.get("CF-Connecting-IP").strip() - - if "X-Forwarded-For" in request.headers: - forwarded_for = request.headers.get("X-Forwarded-For") - ip_list = [ip.strip() for ip in forwarded_for.split(",")] - if ip_list: - return ip_list[0] - - if "X-Real-IP" in request.headers: - return request.headers.get("X-Real-IP").strip() - + headers = request.headers + cf_ip = headers.get("CF-Connecting-IP") + if cf_ip: + return cf_ip.split(",")[0].strip() + xff = headers.get("X-Forwarded-For") + if xff: + return xff.split(",")[0].strip() + x_real_ip = headers.get("X-Real-IP") + if x_real_ip: + return x_real_ip.strip() return request.remote_addr + def is_allowed_ip(remote_ip, allowed_hosts_str): if os.path.exists("emergency_access.txt"): return True