database.cursor.execute("SELECT last_status_code, COUNT(domain) AS score FROM instances WHERE last_status_code IS NOT NULL AND last_status_code != '200' GROUP BY last_status_code ORDER BY score DESC LIMIT ?", [amount])
elif mode == "avg_peers":
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])
+ elif mode == "obfucator":
+ database.cursor.execute("SELECT software, COUNT(domain) AS cnt FROM instances WHERE has_obfucation = 1 GROUP BY software ORDER BY cnt DESC LIMIT ?", [amount])
+ elif mode == "obfucation":
+ database.cursor.execute("SELECT has_obfucation, COUNT(domain) AS cnt FROM instances WHERE software IN ('pleroma', 'mastodon') GROUP BY has_obfucation ORDER BY cnt DESC LIMIT ?", [amount])
else:
raise HTTPException(status_code=400, detail="No filter specified")
response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=error_code&amount={amount}")
elif mode == "avg_peers" and amount > 0:
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}")
+ elif mode == "obfucator" and amount > 0:
+ response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=obfucator&amount={amount}")
+ elif mode == "obfucation" and amount > 0:
+ response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=obfucation&amount={amount}")
else:
raise HTTPException(status_code=400, detail="No filter specified")
logger.debug(f"blocker='{blocker}'")
instances.set_last_blocked(blocker)
- instances.set_has_obsfucation(blocker, False)
+ instances.set_has_obfucation(blocker, False)
if software == "pleroma":
logger.info("blocker='%s',software='%s'", blocker, software)
logger.warning("blocked is empty, blocker='%s'", blocker)
continue
elif blocked.count("*") > 0:
- logger.debug("blocker='%s' uses obsfucated domains, marking ...", blocker)
- instances.set_has_obsfucation(blocker, True)
+ logger.debug("blocker='%s' uses obfucated domains, marking ...", blocker)
+ instances.set_has_obfucation(blocker, True)
# Some friendica servers also obscure domains without hash
- row = instances.deobscure("*", blocked)
+ row = instances.deobfucate("*", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobsfucate blocked='%s',blocker='%s',software='%s' - SKIPPED!", blocked, blocker, software)
+ logger.warning("Cannot deobfucate blocked='%s',blocker='%s',software='%s' - SKIPPED!", blocked, blocker, software)
continue
blocked = row[0]
origin = row[1]
nodeinfo_url = row[2]
elif blocked.count("?") > 0:
- logger.debug("blocker='%s' uses obsfucated domains, marking ...", blocker)
- instances.set_has_obsfucation(blocker, True)
+ logger.debug("blocker='%s' uses obfucated domains, marking ...", blocker)
+ instances.set_has_obfucation(blocker, True)
# Some obscure them with question marks, not sure if that's dependent on version or not
- row = instances.deobscure("?", blocked)
+ row = instances.deobfucate("?", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobsfucate blocked='%s',blocker='%s',software='%s' - SKIPPED!", blocked, blocker, software)
+ logger.warning("Cannot deobfucate blocked='%s',blocker='%s',software='%s' - SKIPPED!", blocked, blocker, software)
continue
blocked = row[0]
"last_status_code" : {},
# Last error details
"last_error_details" : {},
- # Wether obsfucation has been used
- "has_obsfucation" : {},
+ # Wether obfucation has been used
+ "has_obfucation" : {},
}
def _set_data(key: str, domain: str, value: any):
logger.debug("recently='%s' - EXIT!", recently)
return recently
-def deobscure(char: str, domain: str, blocked_hash: str = None) -> tuple:
+def deobfucate(char: str, domain: str, blocked_hash: str = None) -> tuple:
logger.debug("char='%s',domain='%s',blocked_hash='%s' - CALLED!", char, domain, blocked_hash)
if not isinstance(domain, str):
if row is None:
logger.debug("blocked_hash='%s' not found, trying domain='%s' ...", blocked_hash, domain)
- return deobscure(char, domain)
+ return deobfucate(char, domain)
else:
logger.debug("Looking up domain='%s' ...", domain)
database.cursor.execute(
_set_data("detection_mode", domain, mode)
logger.debug("EXIT!")
-def set_has_obsfucation(domain: str, status: bool):
+def set_has_obfucation(domain: str, status: bool):
logger.debug("domain(%d)='%s',status='%s' - CALLED!", len(domain), domain, status)
domain_helper.raise_on(domain)
raise ValueError(f"Parameter status[]='{type(status)}' is not 'bool'")
# Set timestamp
- _set_data("has_obsfucation", domain, status)
+ _set_data("has_obfucation", domain, status)
logger.debug("EXIT!")
logger.warning("blocked is empty, domain='%s'", domain)
continue
elif blocked.count("*") > 0:
- logger.debug("domain='%s' uses obsfucated domains, marking ...", domain)
- instances.set_has_obsfucation(domain, True)
+ logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
+ instances.set_has_obfucation(domain, True)
# Doing the hash search for instance names as well to tidy up DB
- row = instances.deobscure("*", blocked, blocked_hash)
+ row = instances.deobfucate("*", blocked, blocked_hash)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobsfucate blocked='%s',blocked_hash='%s' - SKIPPED!", blocked, blocked_hash)
+ logger.warning("Cannot deobfucate blocked='%s',blocked_hash='%s' - SKIPPED!", blocked, blocked_hash)
continue
logger.debug("Updating domain: row[0]='%s'", row[0])
origin = row[1]
nodeinfo_url = row[2]
elif blocked.count("?") > 0:
- logger.debug("domain='%s' uses obsfucated domains, marking ...", domain)
- instances.set_has_obsfucation(domain, True)
+ logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
+ instances.set_has_obfucation(domain, True)
# Doing the hash search for instance names as well to tidy up DB
- row = instances.deobscure("?", blocked, blocked_hash)
+ row = instances.deobfucate("?", blocked, blocked_hash)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobsfucate blocked='%s',blocked_hash='%s' - SKIPPED!", blocked, blocked_hash)
+ logger.warning("Cannot deobfucate blocked='%s',blocked_hash='%s' - SKIPPED!", blocked, blocked_hash)
continue
logger.debug("Updating domain: row[0]='%s'", row[0])
logger.debug("blocked='%s' is a fake domain - SKIPPED!", blocked)
continue
elif blocked.count("*") > 0:
- logger.debug("domain='%s' uses obsfucated domains, marking ...", domain)
- instances.set_has_obsfucation(domain, True)
+ logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
+ instances.set_has_obfucation(domain, True)
# Obscured domain name with no hash
- row = instances.deobscure("*", blocked)
+ row = instances.deobfucate("*", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobsfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
+ logger.warning("Cannot deobfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
origin = row[1]
nodeinfo_url = row[2]
elif blocked.count("?") > 0:
- logger.debug("domain='%s' uses obsfucated domains, marking ...", domain)
- instances.set_has_obsfucation(domain, True)
+ logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
+ instances.set_has_obfucation(domain, True)
# Obscured domain name with no hash
- row = instances.deobscure("?", blocked)
+ row = instances.deobfucate("?", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobsfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
+ logger.warning("Cannot deobfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
logger.debug("blocked='%s' is a fake domain - SKIPPED!", blocked)
continue
elif blocked.count("*") > 0:
- logger.debug("domain='%s' uses obsfucated domains, marking ...", domain)
- instances.set_has_obsfucation(domain, True)
+ logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
+ instances.set_has_obfucation(domain, True)
# Obscured domain name with no hash
- row = instances.deobscure("*", blocked)
+ row = instances.deobfucate("*", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobsfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
+ logger.warning("Cannot deobfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
origin = row[1]
nodeinfo_url = row[2]
elif blocked.count("?") > 0:
- logger.debug("domain='%s' uses obsfucated domains, marking ...", domain)
- instances.set_has_obsfucation(domain, True)
+ logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
+ instances.set_has_obfucation(domain, True)
# Obscured domain name with no hash
- row = instances.deobscure("?", blocked)
+ row = instances.deobfucate("?", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobsfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
+ logger.warning("Cannot deobfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
origin = row[1]
nodeinfo_url = row[2]
- logger.debug("blocked='%s' - DEOBSFUCATED!", blocked)
+ logger.debug("blocked='%s' - DEOBFUCATED!", blocked)
if not utils.is_domain_wanted(blocked):
logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
continue
logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s'", domain, block_level)
continue
elif blocked.count("*") > 0:
- logger.debug("domain='%s' uses obsfucated domains, marking ...", domain)
- instances.set_has_obsfucation(domain, True)
+ logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
+ instances.set_has_obfucation(domain, True)
# Obscured domain name with no hash
- row = instances.deobscure("*", blocked)
+ row = instances.deobfucate("*", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobsfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
+ logger.warning("Cannot deobfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
origin = row[1]
nodeinfo_url = row[2]
elif blocked.count("?") > 0:
- logger.debug("domain='%s' uses obsfucated domains, marking ...", domain)
- instances.set_has_obsfucation(domain, True)
+ logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
+ instances.set_has_obfucation(domain, True)
# Obscured domain name with no hash
- row = instances.deobscure("?", blocked)
+ row = instances.deobfucate("?", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobsfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
+ logger.warning("Cannot deobfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
origin = row[1]
nodeinfo_url = row[2]
- logger.debug("blocked='%s' - DEOBSFUCATED!", blocked)
+ logger.debug("blocked='%s' - DEOBFUCATED!", blocked)
if not utils.is_domain_wanted(blocked):
logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
continue
logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s'", domain, block_level)
continue
elif blocked.count("*") > 0:
- logger.debug("domain='%s' uses obsfucated domains, marking ...", domain)
- instances.set_has_obsfucation(domain, True)
+ logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
+ instances.set_has_obfucation(domain, True)
# Obscured domain name with no hash
- row = instances.deobscure("*", blocked)
+ row = instances.deobfucate("*", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobsfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
+ logger.warning("Cannot deobfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
origin = row[1]
nodeinfo_url = row[2]
elif blocked.count("?") > 0:
- logger.debug("domain='%s' uses obsfucated domains, marking ...", domain)
- instances.set_has_obsfucation(domain, True)
+ logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
+ instances.set_has_obfucation(domain, True)
# Obscured domain name with no hash
- row = instances.deobscure("?", blocked)
+ row = instances.deobfucate("?", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobsfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
+ logger.warning("Cannot deobfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s'", domain, block_level)
continue
elif blocked.count("*") > 0:
- logger.debug("domain='%s' uses obsfucated domains, marking ...", domain)
- instances.set_has_obsfucation(domain, True)
+ logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
+ instances.set_has_obfucation(domain, True)
# Obscured domain name with no hash
- row = instances.deobscure("*", blocked)
+ row = instances.deobfucate("*", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobsfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
+ logger.warning("Cannot deobfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
origin = row[1]
nodeinfo_url = row[2]
elif blocked.count("?") > 0:
- logger.debug("domain='%s' uses obsfucated domains, marking ...", domain)
- instances.set_has_obsfucation(domain, True)
+ logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
+ instances.set_has_obfucation(domain, True)
# Obscured domain name with no hash
- row = instances.deobscure("?", blocked)
+ row = instances.deobfucate("?", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobsfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
+ logger.warning("Cannot deobfucate blocked='%s',domain='%s',origin='%s' - SKIPPED!", blocked, domain, origin)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
origin = row[1]
nodeinfo_url = row[2]
- logger.debug("blocked='%s' - DEOBSFUCATED!", blocked)
+ logger.debug("blocked='%s' - DEOBFUCATED!", blocked)
if not utils.is_domain_wanted(blocked):
logger.warning("blocked='%s' is not wanted - SKIPPED!", blocked)
continue
raise ValueError("Parameter 'command' is empty")
if domain.find("*") > 0:
- logger.debug("blocker='%s' uses obsfucated domains, marking ...", blocker)
- instances.set_has_obsfucation(blocker, True)
+ logger.debug("blocker='%s' uses obfucated domains, marking ...", blocker)
+ instances.set_has_obfucation(blocker, True)
# Try to de-obscure it
- row = instances.deobscure("*", domain)
+ row = instances.deobfucate("*", domain)
logger.debug(f"row[{type(row)}]='{row}'")
if row is None:
logger.debug(f"domain='{domain}' de-obscured to '{row[0]}'")
domain = row[0]
elif domain.find("?") > 0:
- logger.debug("blocker='%s' uses obsfucated domains, marking ...", blocker)
- instances.set_has_obsfucation(blocker, True)
+ logger.debug("blocker='%s' uses obfucated domains, marking ...", blocker)
+ instances.set_has_obfucation(blocker, True)
# Try to de-obscure it
- row = instances.deobscure("?", domain)
+ row = instances.deobfucate("?", domain)
logger.debug(f"row[{type(row)}]='{row}'")
if row is None:
logger.debug(f"domain='{domain}' de-obscured to '{row[0]}'")
domain = row[0]
else:
- logger.debug("blocker='%s' has NO obsfucation on their block list", blocker)
- instances.set_has_obsfucation(blocker, False)
+ logger.debug("blocker='%s' has NO obfucation on their block list", blocker)
+ instances.set_has_obfucation(blocker, False)
if instances.has_pending(blocker):
logger.debug("Invoking instances.update_data(%s) ...", blocker)
<a href="{{base_url}}/scoreboard?mode=command&amount=10">commands</a> /
<a href="{{base_url}}/scoreboard?mode=error_code&amount=30">error codes</a> /
<a href="{{base_url}}/scoreboard?mode=avg_peers&amount=30">average peers</a> /
- <a href="{{base_url}}/scoreboard?mode=obsfucator&amount=30">obsfucating software</a> /
- <a href="{{base_url}}/scoreboard?mode=obsfucation&amount=10">obsfucation metrics</a>
+ <a href="{{base_url}}/scoreboard?mode=obfucator&amount=30">obfucating software</a> /
+ <a href="{{base_url}}/scoreboard?mode=obfucation&amount=10">obfucation metrics</a>
</p>
{% endblock %}
{% block footer %}
{% extends "base.html" %}
-{% 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 title %}Scoreboard - {% if mode == 'software' %}TOP {{amount}} used software{% elif mode == 'obfucation' %}obfucation metrics{% elif mode == 'obfucator' %}TOP {{amount}} obfucating 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' %}
<h1>TOP {{amount}} error codes</h1>
{% elif mode == 'avg_peers' %}
<h1>TOP {{amount}} average peer count</h1>
- {% elif mode == 'obsfucator' %}
- <h1>TOP {{amount}} obsfucating software</h1>
- {% elif mode == 'obsfucation' %}
- <h1>Obsfucation metrics</h1>
+ {% elif mode == 'obfucator' %}
+ <h1>TOP {{amount}} obfucating software</h1>
+ {% elif mode == 'obfucation' %}
+ <h1>obfucation metrics</h1>
{% endif %}
{% endblock %}
<table>
<thead>
<th>№</th>
- <th>{% if mode in ('software', 'avg_peers', 'obsfucator') %}Software{% elif mode == 'obsfucation' %}Obsfucation status{% elif mode == 'error_code' %}Error code{% else %}Instance{% endif %}</th>
- <th>{% if mode == 'reference' %}References{% elif mode == 'avg_peers' %}Average{% elif mode in('software', 'error_code', 'obsfucator', 'obsfucation') %}Total{% else %}Blocks{% endif %}</th>
+ <th>{% if mode in ('software', 'avg_peers', 'obfucator') %}Software{% elif mode == 'obfucation' %}obfucation status{% elif mode == 'error_code' %}Error code{% else %}Instance{% endif %}</th>
+ <th>{% if mode == 'reference' %}References{% elif mode == 'avg_peers' %}Average{% elif mode in('software', 'error_code', 'obfucator', 'obfucation') %}Total{% else %}Blocks{% endif %}</th>
</thead>
<tbody>
<tr>
<td>{{loop.index}}</td>
<td>
- {% if mode in ('software', 'command', 'error_code', 'avg_peers', 'obsfucator', 'obsfucation') %}
+ {% if mode in ('software', 'command', 'error_code', 'avg_peers', 'obfucator', 'obfucation') %}
{{entry['domain']}}
{% elif entry['domain'] == None %}
-
<li>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.</li>
</ul>
</div>
- {% elif mode == 'obsfucation' %}
+ {% elif mode == 'obfucation' %}
<div class="notes">
- <h2>Please note to obsfucation status:</h2>
+ <h2>Please note to obfucation status:</h2>
<ul>
<li>Only supported networks are counted here.</li>
<li><em>None</em> means not determined yet.</li>