logi
This commit is contained in:
14
app.py
14
app.py
@@ -551,6 +551,15 @@ def attempts_remaining(ip):
|
||||
|
||||
####################################################
|
||||
|
||||
def get_client_ip():
|
||||
# Obsługuje: X-Forwarded-For, X-Real-IP, fallback na remote_addr
|
||||
for header in ["X-Forwarded-For", "X-Real-IP"]:
|
||||
if header in request.headers:
|
||||
# Pierwszy IP w X-Forwarded-For jest najczęściej klientem
|
||||
ip = request.headers[header].split(",")[0].strip()
|
||||
if ip:
|
||||
return ip
|
||||
return request.remote_addr
|
||||
|
||||
@login_manager.user_loader
|
||||
def load_user(user_id):
|
||||
@@ -626,8 +635,9 @@ def start_timer():
|
||||
|
||||
@app.after_request
|
||||
def log_request(response):
|
||||
forwarded_for = request.headers.get("X-Forwarded-For", request.remote_addr)
|
||||
client_ip = forwarded_for.split(",")[0].strip()
|
||||
if request.path == "/healthcheck":
|
||||
return response
|
||||
client_ip = get_client_ip()
|
||||
method = request.method
|
||||
path = request.path
|
||||
status = response.status_code
|
||||
|
Reference in New Issue
Block a user