jtl-wafi-dashboard.py aktualisiert

This commit is contained in:
2025-12-30 15:20:23 +01:00
parent 94bc238149
commit 2ac35b119a

View File

@@ -134,6 +134,8 @@ class ShopData:
top_countries: Dict[str, int] = field(default_factory=dict)
human_requests: int = 0
bot_requests: int = 0
human_rpm: float = 0.0
bot_rpm: float = 0.0
# History für Graph
history: deque = field(default_factory=lambda: deque(maxlen=HISTORY_MAX_POINTS))
@@ -316,6 +318,8 @@ class DataStore:
shop.top_countries = stats.get('top_countries', {})
shop.human_requests = stats.get('human_requests', 0)
shop.bot_requests = stats.get('bot_requests', 0)
shop.human_rpm = stats.get('human_rpm', 0.0)
shop.bot_rpm = stats.get('bot_rpm', 0.0)
# History für Graph
shop.history.append({
@@ -324,7 +328,9 @@ class DataStore:
'active_bot_bans': shop.active_bot_bans,
'active_country_bans': shop.active_country_bans,
'human_requests': shop.human_requests,
'bot_requests': shop.bot_requests
'bot_requests': shop.bot_requests,
'human_rpm': shop.human_rpm,
'bot_rpm': shop.bot_rpm
})
return shop
@@ -351,6 +357,8 @@ class DataStore:
shop.top_countries = stats.get('top_countries', shop.top_countries)
shop.human_requests = stats.get('human_requests', shop.human_requests)
shop.bot_requests = stats.get('bot_requests', shop.bot_requests)
shop.human_rpm = stats.get('human_rpm', shop.human_rpm)
shop.bot_rpm = stats.get('bot_rpm', shop.bot_rpm)
timestamp = utc_now_str()
@@ -361,7 +369,9 @@ class DataStore:
'active_bot_bans': shop.active_bot_bans,
'active_country_bans': shop.active_country_bans,
'human_requests': shop.human_requests,
'bot_requests': shop.bot_requests
'bot_requests': shop.bot_requests,
'human_rpm': shop.human_rpm,
'bot_rpm': shop.bot_rpm
})
# Bot-History aktualisieren
@@ -426,7 +436,9 @@ class DataStore:
'top_ips': shop.top_ips,
'top_countries': shop.top_countries,
'human_requests': shop.human_requests,
'bot_requests': shop.bot_requests
'bot_requests': shop.bot_requests,
'human_rpm': shop.human_rpm,
'bot_rpm': shop.bot_rpm
}
})
return result
@@ -491,6 +503,8 @@ class DataStore:
shops_direct = shops_total - shops_link11
req_per_min = sum(s.req_per_min for s in self.shops.values())
human_rpm = sum(s.human_rpm for s in self.shops.values())
bot_rpm = sum(s.bot_rpm for s in self.shops.values())
active_bot_bans = sum(s.active_bot_bans for s in self.shops.values())
active_country_bans = sum(s.active_country_bans for s in self.shops.values())
@@ -502,6 +516,8 @@ class DataStore:
'shops_link11': shops_link11,
'shops_direct': shops_direct,
'req_per_min': round(req_per_min, 1),
'human_rpm': round(human_rpm, 1),
'bot_rpm': round(bot_rpm, 1),
'active_bot_bans': active_bot_bans,
'active_country_bans': active_country_bans,
'active_bans': active_bot_bans + active_country_bans
@@ -772,6 +788,12 @@ async def agent_websocket(websocket: WebSocket):
'data': event_data
})
elif event_type == 'livestats.result':
await manager.broadcast_to_browsers({
'type': 'livestats.result',
'data': event_data
})
except json.JSONDecodeError:
pass
except Exception as e:
@@ -829,6 +851,51 @@ async def dashboard_websocket(websocket: WebSocket):
'data': {'shop': domain}
})
elif event_type == 'command.livestats':
domain = event_data.get('shop')
agent_id = manager.get_agent_for_shop(domain)
if agent_id:
await manager.send_to_agent(agent_id, {
'type': 'command.livestats',
'data': event_data
})
elif event_type == 'command.ban':
domain = event_data.get('shop')
agent_id = manager.get_agent_for_shop(domain)
if agent_id:
await manager.send_to_agent(agent_id, {
'type': 'command.ban',
'data': event_data
})
elif event_type == 'command.unban':
domain = event_data.get('shop')
agent_id = manager.get_agent_for_shop(domain)
if agent_id:
await manager.send_to_agent(agent_id, {
'type': 'command.unban',
'data': event_data
})
elif event_type == 'command.whitelist':
domain = event_data.get('shop')
agent_id = manager.get_agent_for_shop(domain)
if agent_id:
await manager.send_to_agent(agent_id, {
'type': 'command.whitelist',
'data': event_data
})
elif event_type == 'command.unwhitelist':
domain = event_data.get('shop')
agent_id = manager.get_agent_for_shop(domain)
if agent_id:
await manager.send_to_agent(agent_id, {
'type': 'command.unwhitelist',
'data': event_data
})
elif event_type == 'get_shop_history':
domain = event_data.get('domain')
data = store.get_shop_history(domain)