Log login attempts

This commit is contained in:
Peter Stockings
2026-01-30 19:07:09 +11:00
parent b6443bc1e2
commit 4dcf589b63
4 changed files with 74 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import colorsys
from datetime import datetime, date, timedelta
from flask import request
import numpy as np
@@ -253,6 +254,20 @@ def prepare_svg_plot_data(results, columns, title):
plot_data['plot_type'] = 'table' # Fallback if essential data is missing
return plot_data
def get_client_ip():
"""Get real client IP address, checking proxy headers first"""
# Check common proxy headers in order of preference
if request.headers.get('X-Forwarded-For'):
# X-Forwarded-For can contain multiple IPs, get the first (original client)
return request.headers.get('X-Forwarded-For').split(',')[0].strip()
elif request.headers.get('X-Real-IP'):
return request.headers.get('X-Real-IP')
elif request.headers.get('CF-Connecting-IP'): # Cloudflare
return request.headers.get('CF-Connecting-IP')
else:
# Fallback to direct connection IP
return request.remote_addr
# Calculate ranges (handle datetime separately)
if x_type == 'datetime':
valid_dates = [d for d in x_values_raw if d is not None]