From: Roland Häder Date: Thu, 22 Jun 2023 16:15:09 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2b6083b56bd3d4c075170ef426f6f300654ec4c5;p=fba.git Continued: - added obsfucation metrics, only pleroma and mastodon are currently obsfucating their block list - so also reflect this here --- diff --git a/api.py b/api.py index 3c03c6f..60d0c57 100644 --- a/api.py +++ b/api.py @@ -73,6 +73,8 @@ def api_scoreboard(mode: str, amount: int): database.cursor.execute("SELECT software, AVG(total_peers) AS average FROM instances WHERE software IS NOT NULL GROUP BY software HAVING average>0 ORDER BY average DESC LIMIT ?", [amount]) elif mode == "obsfucator": database.cursor.execute("SELECT software, COUNT(domain) AS cnt FROM instances WHERE has_obsfucation = 1 GROUP BY software ORDER BY cnt DESC LIMIT ?", [amount]) + elif mode == "obsfucation": + database.cursor.execute("SELECT has_obsfucation, COUNT(domain) AS cnt FROM instances WHERE software IN ('pleroma', 'mastodon') GROUP BY has_obsfucation ORDER BY cnt DESC LIMIT ?", [amount]) else: raise HTTPException(status_code=400, detail="No filter specified") @@ -181,6 +183,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=avg_peers&amount={amount}") elif mode == "obsfucator" and amount > 0: response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=obsfucator&amount={amount}") + elif mode == "obsfucation" and amount > 0: + response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=obsfucation&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 87b5602..e1340ff 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -32,7 +32,8 @@ commands / error codes / average peers / - obsfucating software + obsfucating software / + obsfucation metrics

{% endblock %} {% block footer %} diff --git a/templates/views/scoreboard.html b/templates/views/scoreboard.html index b0612ce..53cc3ec 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 == 'obsfucator' %}TOP {{amount}} obsfucating 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 == 'obsfucation' %}Obsfucation metrics{% elif mode == 'obsfucator' %}TOP {{amount}} obsfucating 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' %} @@ -19,6 +19,8 @@

TOP {{amount}} average peer count

{% elif mode == 'obsfucator' %}

TOP {{amount}} obsfucating software

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

Obsfucation metrics

{% endif %} {% endblock %} @@ -27,8 +29,8 @@ - - + + @@ -36,7 +38,7 @@
№{% if mode in ('software', 'avg_peers', 'obsfucator') %}Software{% elif mode == 'error_code' %}Error code{% else %}Instance{% endif %}{% if mode == 'reference' %}References{% elif mode == 'avg_peers' %}Average{% elif mode in('software', 'error_code', 'obsfucator') %}Total{% else %}Blocks{% endif %}{% if mode in ('software', 'avg_peers', 'obsfucator') %}Software{% elif mode == 'obsfucation' %}Obsfucation 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', 'obsfucator', 'obsfucation') %}Total{% else %}Blocks{% endif %}
{{loop.index}} - {% if mode in ('software', 'command', 'error_code', 'avg_peers', 'obsfucator') %} + {% if mode in ('software', 'command', 'error_code', 'avg_peers', 'obsfucator', 'obsfucation') %} {{entry['domain']}} {% elif entry['domain'] == None %} - @@ -60,6 +62,12 @@
  • Error code 999 is fake and covers a lot of reasons why the domain/instance is not reachable. Mostly that the domain is not resolvable or the server refused connection.
+ {% elif mode == 'obsfucation' %} +

Please note to obsfucation status:

+
    +
  • Only supported networks are listed here.
  • +
  • None means not determined yet.
  • +
{% endif %} Index / {{ super() }}