@router.get(config.get("base_url") + "/api/info.json", response_class=JSONResponse)
def api_info():
- database.cursor.execute("SELECT (SELECT COUNT(domain) FROM instances), (SELECT COUNT(domain) FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey', 'peertube', 'takahe', 'gotosocial', 'brighteon', 'wildebeest', 'bookwyrm', 'mitra', 'areionskey')), (SELECT COUNT(blocker) FROM blocks), (SELECT COUNT(domain) FROM instances WHERE last_error_details IS NOT NULL)")
+ database.cursor.execute("SELECT (SELECT COUNT(domain) FROM instances), (SELECT COUNT(domain) FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey', 'peertube', 'takahe', 'gotosocial', 'brighteon', 'wildebeest', 'bookwyrm', 'mitra', 'areionskey', 'mammuthus')), (SELECT COUNT(blocker) FROM blocks), (SELECT COUNT(domain) FROM instances WHERE last_error_details IS NOT NULL)")
row = database.cursor.fetchone()
return JSONResponse(status_code=200, content={
# Loop through some instances
database.cursor.execute(
- "SELECT domain, origin, software, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'lemmy', 'peertube', 'takahe', 'gotosocial', 'brighteon', 'wildebeest', 'bookwyrm', 'mitra', 'areionskey') AND (last_instance_fetch IS NULL OR last_instance_fetch < ?) ORDER BY rowid DESC", [time.time() - config.get("recheck_instance")]
+ "SELECT domain, origin, software, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'lemmy', 'peertube', 'takahe', 'gotosocial', 'brighteon', 'wildebeest', 'bookwyrm', 'mitra', 'areionskey', 'mammuthus') AND (last_instance_fetch IS NULL OR last_instance_fetch < ?) ORDER BY rowid DESC", [time.time() - config.get("recheck_instance")]
)
rows = database.cursor.fetchall()
"everyoneattack.com" : "Floods federation tables with fake nodes",
"vercel.app" : "Floods federation tables with fake nodes",
"run.app" : "Floods federation tables with fake nodes",
+ "denden.world" : "Looks like a valid Mastodon instance, but return exactly (!) 5k instances with trash domains",
"fnaf.stream" : "Trolls with over-long sub-domain name(s)",
"ngrok.io" : "Testing/developing instances shouldn't be part of public instances",
"ngrok.app" : "Testing/developing instances shouldn't be part of public instances",
software = software.split("|")[0]
elif "powered by" in software:
logger.debug("software='%s' has 'powered by' in it", software)
- software = version.strip_powered_by(software)
+ software = strip_powered_by(software)
+ elif software.endswith(" experimental"):
+ logger.debug("software='%s' ends with 'experimental", software)
+ software = strip_until("experimental")
if isinstance(software, str) and " by " in software:
logger.debug("software='%s' has ' by ' in it", software)
- software = version.strip_until(software, " by ")
+ software = strip_until(software, " by ")
elif isinstance(software, str) and " - " in software:
logger.debug("software='%s' has ' - ' in it", software)
- software = version.strip_until(software, " - ")
+ software = strip_until(software, " - ")
elif isinstance(software, str) and " see " in software:
logger.debug("software='%s' has ' see ' in it", software)
- software = version.strip_until(software, " see ")
+ software = strip_until(software, " see ")
logger.debug("software['%s']='%s'", type(software), software)
if software == "":
logger.debug("software[%s]='%s' - EXIT!", type(software), software)
return software
+
+def strip_hosted_on(software: str) -> str:
+ logger.debug("software='%s' - CALLED!", software)
+ if not isinstance(software, str):
+ raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'")
+ elif software == "":
+ raise ValueError("Parameter 'software' is empty")
+ elif "hosted on" not in software:
+ logger.warning("Cannot find 'hosted on' in software='%s'!", software)
+ return software
+
+ end = software.find("hosted on ")
+ logger.debug("end[%s]=%d", type(end), end)
+
+ software = software[0:end].strip()
+ logger.debug("software[%s]='%s'", type(software), software)
+
+ if " - " in software:
+ software = strip_until(software, " - ")
+
+ logger.debug("software='%s' - EXIT!", software)
+ return software
+
+def strip_powered_by(software: str) -> str:
+ logger.debug("software='%s' - CALLED!", software)
+ if not isinstance(software, str):
+ raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'")
+ elif software == "":
+ raise ValueError("Parameter 'software' is empty")
+ elif "powered by" not in software:
+ logger.warning("Cannot find 'powered by' in software='%s'!", software)
+ return software
+
+ start = software.find("powered by ")
+ logger.debug("start[%s]=%d", type(start), start)
+
+ software = software[start + 11:].strip()
+ logger.debug("software='%s'", software)
+
+ if " - " in software:
+ software = strip_until(software, " - ")
+
+ logger.debug("software='%s' - EXIT!", software)
+ return software
+
+def strip_until(software: str, until: str) -> str:
+ logger.debug("software='%s',until='%s' - CALLED!", software, until)
+ if not isinstance(software, str):
+ raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'")
+ elif software == "":
+ raise ValueError("Parameter 'software' is empty")
+ elif not isinstance(until, str):
+ raise ValueError(f"Parameter until[]='{type(until)}' is not of type 'str'")
+ elif until == "":
+ raise ValueError("Parameter 'until' is empty")
+ elif not until in software:
+ logger.warning("Cannot find until='%s' in software='%s'!", until, software)
+ return software
+
+ # Next, strip until part
+ end = software.find(until)
+
+ logger.debug("end[%s]=%d", type(end), end)
+ if end > 0:
+ software = software[0:end].strip()
+
+ logger.debug("software='%s' - EXIT!", software)
+ return software
logger.debug("software='%s' - EXIT!", software)
return software
-
-def strip_powered_by(software: str) -> str:
- logger.debug("software='%s' - CALLED!", software)
- if not isinstance(software, str):
- raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'")
- elif software == "":
- raise ValueError("Parameter 'software' is empty")
- elif "powered by" not in software:
- logger.warning("Cannot find 'powered by' in software='%s'!", software)
- return software
-
- start = software.find("powered by ")
- logger.debug("start[%s]=%d", type(start), start)
-
- software = software[start + 11:].strip()
- logger.debug("software='%s'", software)
-
- if " - " in software:
- software = strip_until(software, " - ")
-
- logger.debug("software='%s' - EXIT!", software)
- return software
-
-def strip_hosted_on(software: str) -> str:
- logger.debug("software='%s' - CALLED!", software)
- if not isinstance(software, str):
- raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'")
- elif software == "":
- raise ValueError("Parameter 'software' is empty")
- elif "hosted on" not in software:
- logger.warning("Cannot find 'hosted on' in software='%s'!", software)
- return software
-
- end = software.find("hosted on ")
- logger.debug("end[%s]=%d", type(end), end)
-
- software = software[0:end].strip()
- logger.debug("software[%s]='%s'", type(software), software)
-
- if " - " in software:
- software = strip_until(software, " - ")
-
- logger.debug("software='%s' - EXIT!", software)
- return software
-
-def strip_until(software: str, until: str) -> str:
- logger.debug("software='%s',until='%s' - CALLED!", software, until)
- if not isinstance(software, str):
- raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'")
- elif software == "":
- raise ValueError("Parameter 'software' is empty")
- elif not isinstance(until, str):
- raise ValueError(f"Parameter until[]='{type(until)}' is not of type 'str'")
- elif until == "":
- raise ValueError("Parameter 'until' is empty")
- elif not until in software:
- logger.warning("Cannot find until='%s' in software='%s'!", until, software)
- return software
-
- # Next, strip until part
- end = software.find(until)
-
- logger.debug("end[%s]=%d", type(end), end)
- if end > 0:
- software = software[0:end].strip()
-
- logger.debug("software='%s' - EXIT!", software)
- return software
logger.debug("software[]='%s'", type(software))
if isinstance(software, str) and "powered by " in software:
logger.debug("software='%s' has 'powered by' in it", software)
- software = version.remove(version.strip_powered_by(software))
+ software = version.remove(software_helper.strip_powered_by(software))
elif isinstance(software, str) and " hosted on " in software:
logger.debug("software='%s' has 'hosted on' in it", software)
- software = version.remove(version.strip_hosted_on(software))
+ software = version.remove(software_helper.strip_hosted_on(software))
elif isinstance(software, str) and " by " in software:
logger.debug("software='%s' has ' by ' in it", software)
- software = version.strip_until(software, " by ")
+ software = software_helper.strip_until(software, " by ")
elif isinstance(software, str) and " see " in software:
logger.debug("software='%s' has ' see ' in it", software)
- software = version.strip_until(software, " see ")
+ software = software_helper.strip_until(software, " see ")
logger.debug("software='%s' - EXIT!", software)
return software
logger.debug("software[]='%s'", type(software))
if isinstance(software, str) and "powered by" in software:
logger.debug("software='%s' has 'powered by' in it", software)
- software = version.remove(version.strip_powered_by(software))
+ software = version.remove(software_helper.strip_powered_by(software))
logger.debug("software='%s' - EXIT!", software)
return software