jtl-wafi-agent.py aktualisiert
This commit is contained in:
@@ -2303,9 +2303,9 @@ if ($detected_bot === null && !empty($user_agent)) {{
|
|||||||
}}
|
}}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
// === STEP 2: Detect Country (only if country_mode active) ===
|
// === STEP 2: Detect Country (always - for logging and stats) ===
|
||||||
$country = 'XX';
|
$country = 'XX';
|
||||||
if ($country_mode && !empty($visitor_ip) && filter_var($visitor_ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false) {{
|
if (!empty($visitor_ip) && filter_var($visitor_ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false) {{
|
||||||
$country = get_country_for_ip($visitor_ip, $country_cache_dir);
|
$country = get_country_for_ip($visitor_ip, $country_cache_dir);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
@@ -3050,6 +3050,14 @@ def get_shop_log_stats(shop: str) -> Dict[str, Any]:
|
|||||||
runtime_minutes = (datetime.now() - activation_time).total_seconds() / 60
|
runtime_minutes = (datetime.now() - activation_time).total_seconds() / 60
|
||||||
if runtime_minutes > 0:
|
if runtime_minutes > 0:
|
||||||
stats['req_per_min'] = round(stats['log_entries'] / runtime_minutes, 2)
|
stats['req_per_min'] = round(stats['log_entries'] / runtime_minutes, 2)
|
||||||
|
stats['human_rpm'] = round(stats['human_requests'] / runtime_minutes, 2)
|
||||||
|
stats['bot_rpm'] = round(stats['bot_requests'] / runtime_minutes, 2)
|
||||||
|
else:
|
||||||
|
stats['human_rpm'] = 0.0
|
||||||
|
stats['bot_rpm'] = 0.0
|
||||||
|
else:
|
||||||
|
stats['human_rpm'] = 0.0
|
||||||
|
stats['bot_rpm'] = 0.0
|
||||||
|
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
@@ -3347,6 +3355,34 @@ class JTLWAFiAgent:
|
|||||||
self._loop
|
self._loop
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Live Stats Tracker updaten
|
||||||
|
try:
|
||||||
|
tracker = get_shop_stats_tracker(shop)
|
||||||
|
|
||||||
|
# IP extrahieren
|
||||||
|
ip = None
|
||||||
|
if 'IP: ' in line:
|
||||||
|
ip = line.split('IP: ')[1].split(' |')[0].strip()
|
||||||
|
|
||||||
|
# Path extrahieren
|
||||||
|
path = '/'
|
||||||
|
if 'Path: ' in line:
|
||||||
|
path = line.split('Path: ')[1].split(' |')[0].strip()
|
||||||
|
|
||||||
|
# Bot/Human erkennen
|
||||||
|
is_bot = any(x in line for x in ['BOT: ', 'BOT:', 'BLOCKED_BOT:', 'MONITOR_BOT:', 'BANNED_BOT:'])
|
||||||
|
|
||||||
|
# Blocked erkennen
|
||||||
|
is_blocked = any(x in line for x in ['BANNED', 'BLOCKED'])
|
||||||
|
|
||||||
|
# 404 erkennen
|
||||||
|
is_404 = '404' in line
|
||||||
|
|
||||||
|
if ip:
|
||||||
|
tracker.record_request(ip, path, is_bot, is_blocked, is_404)
|
||||||
|
except Exception as e:
|
||||||
|
logger.debug(f"LiveStats record error: {e}")
|
||||||
|
|
||||||
# Prüfe auf Ban-Events
|
# Prüfe auf Ban-Events
|
||||||
if 'BANNED: ' in line:
|
if 'BANNED: ' in line:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user