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 == "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', 'friendica') GROUP BY has_obfucation ORDER BY cnt DESC LIMIT ?", [amount])
+ elif mode == "obfuscator":
+ 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])
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 == "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}")
+ elif mode == "obfuscator" and amount > 0:
+ 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}")
else:
raise HTTPException(status_code=400, detail="No filter specified")
logger.debug("blocker='%s'", blocker)
instances.set_last_blocked(blocker)
- instances.set_has_obfucation(blocker, False)
+ instances.set_has_obfuscation(blocker, False)
blocking = list()
if software == "pleroma":
logger.warning("blocked is empty, blocker='%s'", blocker)
continue
elif block['blocked'].count("*") > 0:
- logger.debug("blocker='%s' uses obfucated domains, marking ...", blocker)
- instances.set_has_obfucation(blocker, True)
+ logger.debug("blocker='%s' uses obfuscated domains, marking ...", blocker)
+ instances.set_has_obfuscation(blocker, True)
# Some friendica servers also obscure domains without hash
- row = instances.deobfucate("*", block['blocked'])
+ row = instances.deobfuscate("*", block['blocked'])
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobfucate blocked='%s',blocker='%s',software='%s' - SKIPPED!", block['blocked'], blocker, software)
+ logger.warning("Cannot deobfuscate blocked='%s',blocker='%s',software='%s' - SKIPPED!", block['blocked'], blocker, software)
continue
block['blocked'] = row[0]
origin = row[1]
nodeinfo_url = row[2]
elif block['blocked'].count("?") > 0:
- logger.debug("blocker='%s' uses obfucated domains, marking ...", blocker)
- instances.set_has_obfucation(blocker, True)
+ logger.debug("blocker='%s' uses obfuscated domains, marking ...", blocker)
+ instances.set_has_obfuscation(blocker, True)
# Some obscure them with question marks, not sure if that's dependent on version or not
- row = instances.deobfucate("?", block['blocked'])
+ row = instances.deobfuscate("?", block['blocked'])
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobfucate blocked='%s',blocker='%s',software='%s' - SKIPPED!", block['blocked'], blocker, software)
+ logger.warning("Cannot deobfuscate blocked='%s',blocker='%s',software='%s' - SKIPPED!", block['blocked'], blocker, software)
continue
block['blocked'] = row[0]
"last_status_code" : {},
# Last error details
"last_error_details" : {},
- # Wether obfucation has been used
- "has_obfucation" : {},
+ # Wether obfuscation has been used
+ "has_obfuscation" : {},
}
def _set_data(key: str, domain: str, value: any):
logger.debug("recently='%s' - EXIT!", recently)
return recently
-def deobfucate(char: str, domain: str, blocked_hash: str = None) -> tuple:
+def deobfuscate(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 deobfucate(char, domain)
+ return deobfuscate(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_obfucation(domain: str, status: bool):
+def set_has_obfuscation(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_obfucation", domain, status)
+ _set_data("has_obfuscation", domain, status)
logger.debug("EXIT!")
logger.debug("line[]='%s' returned empty blocked domain - SKIPPED!")
continue
elif blocked.count("*") > 0:
- logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
- instances.set_has_obfucation(domain, True)
+ logger.debug("domain='%s' uses obfuscated domains, marking ...", domain)
+ instances.set_has_obfuscation(domain, True)
# Obscured domain name with no hash
- row = instances.deobfucate("*", blocked)
+ row = instances.deobfuscate("*", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobfucate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
+ logger.warning("Cannot deobfuscate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
blocked = row[0]
elif blocked.count("?") > 0:
- logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
- instances.set_has_obfucation(domain, True)
+ logger.debug("domain='%s' uses obfuscated domains, marking ...", domain)
+ instances.set_has_obfuscation(domain, True)
# Obscured domain name with no hash
- row = instances.deobfucate("?", blocked)
+ row = instances.deobfuscate("?", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobfucate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
+ logger.warning("Cannot deobfuscate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
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 obfucated domains, marking ...", domain)
- instances.set_has_obfucation(domain, True)
+ logger.debug("domain='%s' uses obfuscated domains, marking ...", domain)
+ instances.set_has_obfuscation(domain, True)
# Obscured domain name with no hash
- row = instances.deobfucate("*", blocked)
+ row = instances.deobfuscate("*", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobfucate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
+ logger.warning("Cannot deobfuscate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
blocked = row[0]
elif blocked.count("?") > 0:
- logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
- instances.set_has_obfucation(domain, True)
+ logger.debug("domain='%s' uses obfuscated domains, marking ...", domain)
+ instances.set_has_obfuscation(domain, True)
# Obscured domain name with no hash
- row = instances.deobfucate("?", blocked)
+ row = instances.deobfuscate("?", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobfucate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
+ logger.warning("Cannot deobfuscate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
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 obfucated domains, marking ...", domain)
- instances.set_has_obfucation(domain, True)
+ logger.debug("domain='%s' uses obfuscated domains, marking ...", domain)
+ instances.set_has_obfuscation(domain, True)
# Obscured domain name with no hash
- row = instances.deobfucate("*", blocked)
+ row = instances.deobfuscate("*", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobfucate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
+ logger.warning("Cannot deobfuscate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
blocked = row[0]
elif blocked.count("?") > 0:
- logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
- instances.set_has_obfucation(domain, True)
+ logger.debug("domain='%s' uses obfuscated domains, marking ...", domain)
+ instances.set_has_obfuscation(domain, True)
# Obscured domain name with no hash
- row = instances.deobfucate("?", blocked)
+ row = instances.deobfuscate("?", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobfucate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
+ logger.warning("Cannot deobfuscate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
blocked = row[0]
- logger.debug("blocked='%s' - DEOBFUCATED!", blocked)
+ logger.debug("blocked='%s' - DEobfuscatED!", 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 obfucated domains, marking ...", domain)
- instances.set_has_obfucation(domain, True)
+ logger.debug("domain='%s' uses obfuscated domains, marking ...", domain)
+ instances.set_has_obfuscation(domain, True)
# Obscured domain name with no hash
- row = instances.deobfucate("*", blocked)
+ row = instances.deobfuscate("*", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobfucate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
+ logger.warning("Cannot deobfuscate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
blocked = row[0]
elif blocked.count("?") > 0:
- logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
- instances.set_has_obfucation(domain, True)
+ logger.debug("domain='%s' uses obfuscated domains, marking ...", domain)
+ instances.set_has_obfuscation(domain, True)
# Obscured domain name with no hash
- row = instances.deobfucate("?", blocked)
+ row = instances.deobfuscate("?", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobfucate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
+ logger.warning("Cannot deobfuscate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
blocked = row[0]
- logger.debug("blocked='%s' - DEOBFUCATED!", blocked)
+ logger.debug("blocked='%s' - DEobfuscatED!", 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 obfucated domains, marking ...", domain)
- instances.set_has_obfucation(domain, True)
+ logger.debug("domain='%s' uses obfuscated domains, marking ...", domain)
+ instances.set_has_obfuscation(domain, True)
# Obscured domain name with no hash
- row = instances.deobfucate("*", blocked)
+ row = instances.deobfuscate("*", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobfucate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
+ logger.warning("Cannot deobfuscate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
blocked = row[0]
elif blocked.count("?") > 0:
- logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
- instances.set_has_obfucation(domain, True)
+ logger.debug("domain='%s' uses obfuscated domains, marking ...", domain)
+ instances.set_has_obfuscation(domain, True)
# Obscured domain name with no hash
- row = instances.deobfucate("?", blocked)
+ row = instances.deobfuscate("?", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobfucate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
+ logger.warning("Cannot deobfuscate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
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 obfucated domains, marking ...", domain)
- instances.set_has_obfucation(domain, True)
+ logger.debug("domain='%s' uses obfuscated domains, marking ...", domain)
+ instances.set_has_obfuscation(domain, True)
# Obscured domain name with no hash
- row = instances.deobfucate("*", blocked)
+ row = instances.deobfuscate("*", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobfucate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
+ logger.warning("Cannot deobfuscate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
blocked = row[0]
elif blocked.count("?") > 0:
- logger.debug("domain='%s' uses obfucated domains, marking ...", domain)
- instances.set_has_obfucation(domain, True)
+ logger.debug("domain='%s' uses obfuscated domains, marking ...", domain)
+ instances.set_has_obfuscation(domain, True)
# Obscured domain name with no hash
- row = instances.deobfucate("?", blocked)
+ row = instances.deobfuscate("?", blocked)
logger.debug("row[]='%s'", type(row))
if row is None:
- logger.warning("Cannot deobfucate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
+ logger.warning("Cannot deobfuscate blocked='%s',domain='%s' - SKIPPED!", blocked, domain)
continue
logger.debug("blocked='%s' de-obscured to '%s'", blocked, row[0])
blocked = row[0]
- logger.debug("blocked='%s' - DEOBFUCATED!", blocked)
+ logger.debug("blocked='%s' - DEobfuscatED!", 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 obfucated domains, marking ...", blocker)
- instances.set_has_obfucation(blocker, True)
+ logger.debug("blocker='%s' uses obfuscated domains, marking ...", blocker)
+ instances.set_has_obfuscation(blocker, True)
# Try to de-obscure it
- row = instances.deobfucate("*", domain)
+ row = instances.deobfuscate("*", domain)
logger.debug(f"row[{type(row)}]='{row}'")
if row is None:
- logger.warning("Cannot de-obfucate domain='%s' - SKIPPED!", domain)
+ logger.warning("Cannot de-obfuscate domain='%s' - SKIPPED!", domain)
return False
logger.debug(f"domain='{domain}' de-obscured to '{row[0]}'")
domain = row[0]
elif domain.find("?") > 0:
- logger.debug("blocker='%s' uses obfucated domains, marking ...", blocker)
- instances.set_has_obfucation(blocker, True)
+ logger.debug("blocker='%s' uses obfuscated domains, marking ...", blocker)
+ instances.set_has_obfuscation(blocker, True)
# Try to de-obscure it
- row = instances.deobfucate("?", domain)
+ row = instances.deobfuscate("?", domain)
logger.debug(f"row[{type(row)}]='{row}'")
if row is None:
- logger.warning("Cannot de-obfucate domain='%s' - SKIPPED!", domain)
+ logger.warning("Cannot de-obfuscate domain='%s' - SKIPPED!", domain)
return False
logger.debug(f"domain='{domain}' de-obscured to '{row[0]}'")
domain = row[0]
else:
- logger.debug("blocker='%s' has NO obfucation on their block list", blocker)
- instances.set_has_obfucation(blocker, False)
+ logger.debug("blocker='%s' has NO obfuscation on their block list", blocker)
+ instances.set_has_obfuscation(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=obfucator&amount=30">obfucating software</a> /
- <a href="{{base_url}}/scoreboard?mode=obfucation&amount=10">obfucation metrics</a>
+ <a href="{{base_url}}/scoreboard?mode=obfuscator&amount=30">obfuscating software</a> /
+ <a href="{{base_url}}/scoreboard?mode=obfuscation&amount=10">obfuscation metrics</a>
</p>
{% endblock %}
{% block footer %}
{% extends "base.html" %}
-{% 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 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 header %}
{% if mode == 'blocker' %}
<h1>TOP {{amount}} error codes</h1>
{% elif mode == 'avg_peers' %}
<h1>TOP {{amount}} average peer count</h1>
- {% elif mode == 'obfucator' %}
- <h1>TOP {{amount}} obfucating software</h1>
- {% elif mode == 'obfucation' %}
- <h1>obfucation metrics</h1>
+ {% elif mode == 'obfuscator' %}
+ <h1>TOP {{amount}} obfuscating software</h1>
+ {% elif mode == 'obfuscation' %}
+ <h1>obfuscation metrics</h1>
{% endif %}
{% endblock %}
<table>
<thead>
<th>№</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>
+ <th>{% if mode in ('software', 'avg_peers', 'obfuscator') %}Software{% elif mode == 'obfuscation' %}obfuscation 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', 'obfuscator', 'obfuscation') %}Total{% else %}Blocks{% endif %}</th>
</thead>
<tbody>
<tr>
<td>{{loop.index}}</td>
<td>
- {% if mode in ('software', 'command', 'error_code', 'avg_peers', 'obfucator', 'obfucation') %}
+ {% if mode in ('software', 'command', 'error_code', 'avg_peers', 'obfuscator', 'obfuscation') %}
{{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 == 'obfucation' %}
+ {% elif mode == 'obfuscation' %}
<div class="notes">
- <h2>Please note to obfucation status:</h2>
+ <h2>Please note to obfuscation status:</h2>
<ul>
<li>Only supported networks are counted here.</li>
<li><em>None</em> means not determined yet.</li>