From: Roland Häder Date: Thu, 22 Jun 2023 22:46:40 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=266231cf1c97e56f414b1268e74057c1f6394889;p=fba.git Continued: - added metrics for blocking levels --- diff --git a/api.py b/api.py index 9217716..7ffa3c3 100644 --- a/api.py +++ b/api.py @@ -75,6 +75,8 @@ def api_scoreboard(mode: str, amount: int): database.cursor.execute("SELECT software, COUNT(domain) AS cnt FROM instances WHERE has_obfuscation = 1 GROUP BY software ORDER BY cnt DESC LIMIT ?", [amount]) elif mode == "obfuscation": database.cursor.execute("SELECT has_obfuscation, COUNT(domain) AS cnt FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica') GROUP BY has_obfuscation ORDER BY cnt DESC LIMIT ?", [amount]) + elif mode == "block_level": + database.cursor.execute("SELECT block_level, COUNT(rowid) AS cnt FROM blocks GROUP BY block_level ORDER BY cnt DESC LIMIT ?", [amount]) else: raise HTTPException(status_code=400, detail="No filter specified") @@ -185,6 +187,8 @@ def scoreboard(request: Request, mode: str, amount: int): response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=obfuscator&amount={amount}") elif mode == "obfuscation" and amount > 0: response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=obfuscation&amount={amount}") + elif mode == "block_level" and amount > 0: + response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=block_level&amount={amount}") else: raise HTTPException(status_code=400, detail="No filter specified") diff --git a/templates/views/index.html b/templates/views/index.html index 4c91f2b..a179703 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -33,7 +33,8 @@ error codes / average peers / obfuscating software / - obfuscation metrics + obfuscation metrics / + block level metrics

{% endblock %} {% block footer %} diff --git a/templates/views/scoreboard.html b/templates/views/scoreboard.html index 547a5ea..b4615e1 100644 --- a/templates/views/scoreboard.html +++ b/templates/views/scoreboard.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block title %}Scoreboard - {% if mode == 'software' %}TOP {{amount}} used software{% elif mode == 'obfuscation' %}obfuscation metrics{% elif mode == 'obfuscator' %}TOP {{amount}} obfuscating software{% elif mode == 'avg_peers' %}TOP {{amount}} average peer count{% elif mode == 'command' %}TOP {{amount}} commands{% elif mode == 'error_code' %}TOP {{amount}} error codes{% elif mode == 'reference' %}TOP {{amount}} referencing instances{% elif mode == 'blocked' %}TOP {{amount}} deferated instances{% elif mode == 'blocker' %}TOP {{amount}} deferating instances{% endif %}{% endblock %} +{% block title %}Scoreboard - {% if mode == 'software' %}TOP {{amount}} used software{% elif mode == 'block_level' %}TOP {{amount}} block level metrics{% elif mode == 'obfuscation' %}obfuscation metrics{% elif mode == 'obfuscator' %}TOP {{amount}} obfuscating software{% elif mode == 'avg_peers' %}TOP {{amount}} average peer count{% elif mode == 'command' %}TOP {{amount}} commands{% elif mode == 'error_code' %}TOP {{amount}} error codes{% elif mode == 'reference' %}TOP {{amount}} referencing instances{% elif mode == 'blocked' %}TOP {{amount}} deferated instances{% elif mode == 'blocker' %}TOP {{amount}} deferating instances{% endif %}{% endblock %} {% block header %} {% if mode == 'blocker' %} @@ -21,6 +21,8 @@

TOP {{amount}} obfuscating software

{% elif mode == 'obfuscation' %}

obfuscation metrics

+ {% elif mode == 'block_level' %} +

TOP {{amount}} block levels

{% endif %} {% endblock %} @@ -30,7 +32,7 @@ № {% if mode in ('software', 'avg_peers', 'obfuscator') %}Software{% elif mode == 'obfuscation' %}obfuscation status{% elif mode == 'error_code' %}Error code{% else %}Instance{% endif %} - {% if mode == 'reference' %}References{% elif mode == 'avg_peers' %}Average{% elif mode in('software', 'error_code', 'obfuscator', 'obfuscation') %}Total{% else %}Blocks{% endif %} + {% if mode == 'reference' %}References{% elif mode == 'avg_peers' %}Average{% elif mode in('software', 'error_code', 'obfuscator', 'obfuscation', 'block_level') %}Total{% else %}Blocks{% endif %} @@ -38,7 +40,7 @@ {{loop.index}} - {% if mode in ('software', 'command', 'error_code', 'avg_peers', 'obfuscator', 'obfuscation') %} + {% if mode in ('software', 'command', 'error_code', 'avg_peers', 'obfuscator', 'obfuscation', 'block_level') %} {{entry['domain']}} {% elif entry['domain'] == None %} -