}
@router.get(config.get("base_url") + "/api/top.json", response_class=JSONResponse)
-def top(blocked: int = None, blockers: int = None, reference: int = None, software: int = None, originator: int = None, error_code: int = None):
+def top(blocked: int = None, blockers: int = None, reference: int = None, software: int = None, command: int = None, error_code: int = None):
if blocked is not None:
if blocked > 500:
raise HTTPException(status_code=400, detail="Too many results")
if software > 500:
raise HTTPException(status_code=400, detail="Too many results")
fba.cursor.execute("SELECT software, COUNT(domain) FROM instances WHERE software IS NOT NULL GROUP BY software ORDER BY COUNT(domain) DESC, software ASC LIMIT ?", [software])
- elif originator is not None:
- if originator > 500:
+ elif command is not None:
+ if command > 500:
raise HTTPException(status_code=400, detail="Too many results")
- fba.cursor.execute("SELECT originator, COUNT(domain) FROM instances WHERE originator IS NOT NULL GROUP BY originator ORDER BY COUNT(domain) DESC, originator ASC LIMIT ?", [originator])
+ fba.cursor.execute("SELECT command, COUNT(domain) FROM instances WHERE command IS NOT NULL GROUP BY command ORDER BY COUNT(domain) DESC, command ASC LIMIT ?", [command])
elif error_code is not None:
if error_code > 500:
raise HTTPException(status_code=400, detail="Too many results")
return JSONResponse(status_code=200, content={})
@router.get(config.get("base_url") + "/scoreboard")
-def scoreboard(request: Request, blockers: int = None, blocked: int = None, reference: int = None, software: int = None, originator: int = None, error_code: int = None):
+def scoreboard(request: Request, blockers: int = None, blocked: int = None, reference: int = None, software: int = None, command: int = None, error_code: int = None):
if blockers is not None and blockers > 0:
response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?blockers={blockers}")
elif blocked is not None and blocked > 0:
response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?reference={reference}")
elif software is not None and software > 0:
response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?software={software}")
- elif originator is not None and originator > 0:
- response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?originator={originator}")
+ elif command is not None and command > 0:
+ response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?command={command}")
elif error_code is not None and error_code > 0:
response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?error_code={error_code}")
else:
"blocked" : blocked,
"reference" : reference,
"software" : software,
- "originator": originator,
+ "command" : command,
"error_code": error_code,
"scores" : fba.json_from_response(response)
})
# DEBUG: print("DEBUG: EXIT!")
-def add(domain: str, origin: str, originator: str, path: str = None):
- # DEBUG: print(f"DEBUG: domain='{domain}',origin='{origin}',originator='{originator}',path='{path}' - CALLED!")
+def add(domain: str, origin: str, command: str, path: str = None):
+ # DEBUG: print(f"DEBUG: domain='{domain}',origin='{origin}',command='{command}',path='{path}' - CALLED!")
if not isinstance(domain, str):
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
elif domain == "":
raise ValueError(f"origin[]={type(origin)} is not 'str'")
elif origin == "":
raise ValueError("Parameter 'origin' is empty")
- elif not isinstance(originator, str):
- raise ValueError(f"originator[]={type(originator)} is not 'str'")
- elif originator == "":
- raise ValueError("Parameter 'originator' is empty")
+ elif not isinstance(command, str):
+ raise ValueError(f"command[]={type(command)} is not 'str'")
+ elif command == "":
+ raise ValueError("Parameter 'command' is empty")
elif not validators.domain(domain.split("/")[0]):
raise ValueError(f"Bad domain name='{domain}'")
elif origin is not None and not validators.domain(origin.split("/")[0]):
elif domain.find("/profile/") > 0 or domain.find("/users/") > 0:
raise Exception(f"domain='{domain}' is a single user")
- # DEBUG: print("DEBUG: domain,origin,originator,path:", domain, origin, originator, path)
+ # DEBUG: print("DEBUG: domain,origin,command,path:", domain, origin, command, path)
software = fba.determine_software(domain, path)
# DEBUG: print("DEBUG: Determined software:", software)
if domain.find("/c/") > 0 and software == "lemmy":
print(f"INFO: Adding instance domain='{domain}' (origin='{origin}',software='{software}')")
try:
fba.cursor.execute(
- "INSERT INTO instances (domain, origin, originator, hash, software, first_seen) VALUES (?, ?, ?, ?, ?, ?)",
+ "INSERT INTO instances (domain, origin, command, hash, software, first_seen) VALUES (?, ?, ?, ?, ?, ?)",
(
domain,
origin,
- originator,
+ command,
fba.get_hash(domain),
software,
time.time()
<a href="{{base_url}}/scoreboard?blocked=50">defederated instances</a> /
<a href="{{base_url}}/scoreboard?reference=50">referencing instances</a> /
<a href="{{base_url}}/scoreboard?software=50">used software</a> /
- <a href="{{base_url}}/scoreboard?originator=10">originators</a> /
+ <a href="{{base_url}}/scoreboard?command=10">commands</a> /
<a href="{{base_url}}/scoreboard?error_code=30">error codes</a>
</p>
{% endblock %}
{% extends "base.html" %}
-{% block title %}scoreboard - {% if software %}TOP {{software}} used software{% elif originator %}TOP {{originator}} scripts{% elif reference %}TOP {{reference}} referencing instances{% elif blocked %}TOP {{blocked}} deferated instances{% elif blockers %}TOP {{blockers}} deferating instances{% endif %}{% endblock %}
+{% block title %}scoreboard - {% if software %}TOP {{software}} used software{% elif command %}TOP {{command}} scripts{% elif reference %}TOP {{reference}} referencing instances{% elif blocked %}TOP {{blocked}} deferated instances{% elif blockers %}TOP {{blockers}} deferating instances{% endif %}{% endblock %}
{% block header %}
{% if blockers %}
<h1>Top {{reference}} referencing instances</h1>
{% elif software %}
<h1>Top {{software}} used software</h1>
- {% elif originator %}
- <h1>TOP {{originator}} scripts</h1>
+ {% elif command %}
+ <h1>TOP {{command}} scripts</h1>
{% elif error_code %}
<h1>TOP {{error_code}} error codes</h1>
{% endif %}
<tr>
<td>{{loop.index}}</td>
<td>
- {% if software or originator or error_code %}
+ {% if software or command or error_code %}
{{entry['domain']}}
{% elif entry['domain'] == None %}
-