}
@app.get(fba.config["base_url"] + "/top")
-def top(blocked: int = None, blockers: int = None, reference: int = None):
- if blocked == None and blockers == None and reference == None:
- raise HTTPException(status_code=400, detail="No filter specified")
- elif blocked != None:
+def top(blocked: int = None, blockers: int = None, reference: int = None, software: int = None):
+ if blocked != None:
if blocked > 500:
raise HTTPException(status_code=400, detail="Too many results")
- fba.c.execute("SELECT blocked, COUNT(blocked) FROM blocks WHERE block_level = 'reject' group by blocked ORDER BY COUNT(blocked) DESC LIMIT ?", [blocked])
+ fba.c.execute("SELECT blocked, COUNT(blocked) FROM blocks WHERE block_level = 'reject' GROUP BY blocked ORDER BY COUNT(blocked) DESC LIMIT ?", [blocked])
elif blockers != None:
if blockers > 500:
raise HTTPException(status_code=400, detail="Too many results")
- fba.c.execute("SELECT blocker, COUNT(blocker) FROM blocks WHERE block_level = 'reject' group by blocker ORDER BY COUNT(blocker) DESC LIMIT ?", [blockers])
+ fba.c.execute("SELECT blocker, COUNT(blocker) FROM blocks WHERE block_level = 'reject' GROUP BY blocker ORDER BY COUNT(blocker) DESC LIMIT ?", [blockers])
elif reference != None:
if reference > 500:
raise HTTPException(status_code=400, detail="Too many results")
- fba.c.execute("SELECT origin, COUNT(domain) FROM instances ORDER BY COUNT(domain) DESC LIMIT ?", [reference])
+ fba.c.execute("SELECT origin, COUNT(domain) FROM instances GROUP BY origin ORDER BY COUNT(domain) DESC LIMIT ?", [reference])
+ elif software != None:
+ if software > 500:
+ raise HTTPException(status_code=400, detail="Too many results")
+ fba.c.execute("SELECT software, COUNT(domain) FROM instances GROUP BY software ORDER BY COUNT(domain) DESC LIMIT ?", [software])
+ else:
+ raise HTTPException(status_code=400, detail="No filter specified")
scores = fba.c.fetchall()
result = {}
for blocker, blocked, block_level, reason, first_added, last_seen in blocks:
entry = {
- "blocker": blocker,
- "blocked": blocked,
- "reason": reason,
+ "blocker" : blocker,
+ "blocked" : blocked,
+ "reason" : reason,
"first_added": first_added,
- "last_seen": last_seen
+ "last_seen" : last_seen
}
if block_level in result:
result[block_level].append(entry)
return result
@app.get(fba.config["base_url"] + "/scoreboard")
-def index(request: Request, blockers: int = None, blocked: int = None, reference: int = None, ):
+def index(request: Request, blockers: int = None, blocked: int = None, reference: int = None, software: int = None):
scores = None
- if blockers == None and blocked == None and reference == None:
- raise HTTPException(status_code=400, detail="No filter specified")
- elif blockers != None:
+ if blockers != None and blockers > 0:
scores = requests.get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/top?blockers={blockers}")
- elif blocked != None:
+ elif blocked != None and blocked > 0:
scores = requests.get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/top?blocked={blocked}")
- elif reference != None:
+ elif reference != None and reference > 0:
scores = requests.get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/top?reference={reference}")
+ elif software != None and software > 0:
+ scores = requests.get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/top?software={software}")
+ else:
+ raise HTTPException(status_code=400, detail="No filter specified")
- if scores = None:
+ if scores == None:
raise HTTPException(status_code=500, detail="Could not determine scores")
elif not scores.ok:
raise HTTPException(status_code=scores.status_code, detail=scores.text)
"blockers" : blockers,
"blocked" : blocked,
"reference" : reference,
+ "software" : software,
"scores" : scores.json()
})
<h1>Top {{blocked}} defederated instances</h1>
{% elif reference %}
<h1>Top {{reference}} referencing instances</h1>
+ {% elif software %}
+ <h1>Top {{software}} used software</h1>
{% endif %}
<div class="scoreboard">
<table>
<th>№</th>
- <th>Instance</th>
- <th>{% if reference %}References{% else %}Blocks{% endif %}</th>
+ <th>{% if software %}Software{% else %}Instance{% endif %}</th>
+ <th>{% if reference %}References{% elif software %}Total{% else %}Blocks{% endif %}</th>
{% for entry in scores %}
<tr>
<td>{{loop.index}}</td>
<td>
- <img src="https://proxy.duckduckgo.com/ip3/{{entry['domain']}}.ico" width="16" />
- <b><a href="../?{% if blockers %}reverse{% elif blocked %}domain{% endif %}={{entry['domain']}}" rel="nofollow noopener noreferrer">{{entry['domain']}}</a></b>
- <a class="listlink" href="https://{{entry['domain']}}" rel="external" target="_blank">↗</a>
+ {% if software %}
+ {{entry['domain']}}
+ {% else %}
+ <b><a href="../?{% if blockers %}reverse{% elif blocked %}domain{% endif %}={{entry['domain']}}" rel="nofollow noopener noreferrer">{{entry['domain']}}</a></b>
+ <a class="listlink" href="https://{{entry['domain']}}" rel="external" target="_blank">↗</a>
+ {% endif %}
</td>
<td>{{entry['highscore']}}</td>
</tr>
<p>
<a href="./scoreboard?blockers=50">top 50 defederating</a> /
<a href="./scoreboard?blocked=50">defederated instances</a> /
- <a href="./scoreboard?reference=50">referencing instances</a>
+ <a href="./scoreboard?reference=50">referencing instances</a> /
+ <a href="./scoreboard?software=50">used software</a>
</p>
<div class="info">
known instances: {{info.known_instances}}<br/>