zmiany w acl

This commit is contained in:
Mateusz Gruszczyński 2025-05-13 07:57:56 +02:00
parent 9cc6730291
commit 3d54f95a01

24
app.py
View File

@ -63,22 +63,20 @@ def load_user(user_id):
return User.query.get(int(user_id)) return User.query.get(int(user_id))
def get_real_ip(): def get_real_ip():
headers = request.headers
if "CF-Connecting-IP" in request.headers: cf_ip = headers.get("CF-Connecting-IP")
return request.headers.get("CF-Connecting-IP").strip() if cf_ip:
return cf_ip.split(",")[0].strip()
if "X-Forwarded-For" in request.headers: xff = headers.get("X-Forwarded-For")
forwarded_for = request.headers.get("X-Forwarded-For") if xff:
ip_list = [ip.strip() for ip in forwarded_for.split(",")] return xff.split(",")[0].strip()
if ip_list: x_real_ip = headers.get("X-Real-IP")
return ip_list[0] if x_real_ip:
return x_real_ip.strip()
if "X-Real-IP" in request.headers:
return request.headers.get("X-Real-IP").strip()
return request.remote_addr return request.remote_addr
def is_allowed_ip(remote_ip, allowed_hosts_str): def is_allowed_ip(remote_ip, allowed_hosts_str):
if os.path.exists("emergency_access.txt"): if os.path.exists("emergency_access.txt"):
return True return True