"fetch_blocks",
help="Fetches blocks from registered instances (run command fetch_instances first!).",
)
+ parser.set_defaults(command=commands.fetch_blocks)
parser.add_argument("--domain", help="Instance name (aka. domain)")
parser.add_argument("--software", help="Name of software, e.g. 'lemmy'")
- parser.set_defaults(command=commands.fetch_blocks)
+ parser.add_argument("--force", action="store_true", help="Forces update of data, no matter what.")
### Fetch blocks from chaos.social ###
parser = subparser_command.add_parser(
if args.domain is not None and args.domain != "":
# Re-check single domain
- logger.debug("Querying database for single args.domain='%s' ...", args.domain)
+ logger.debug("Querying database for args.domain='%s' ...", args.domain)
database.cursor.execute(
"SELECT domain, software, origin, nodeinfo_url FROM instances WHERE domain = ?", [args.domain]
)
database.cursor.execute(
"SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software = ? AND nodeinfo_url IS NOT NULL", [args.software]
)
+ elif args.force:
+ # Re-check all
+ logger.debug("Re-checking all instances ...")
+ database.cursor.execute(
+ "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey') AND nodeinfo_url IS NOT NULL ORDER BY rowid DESC"
+ )
else:
# Re-check after "timeout" (aka. minimum interval)
database.cursor.execute(
"grid.tf" : "Floods federation tables with fake nodes",
"gitpod.io" : "Floods federation tables with fake nodes",
"everyoneattack.com" : "Floods federation tables with fake nodes",
+ "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",
"ngrok-free.app" : "Testing/developing instances shouldn't be part of public instances",
logger.debug("domain='%s' is not registered, returning False - EXIT!", domain)
return False
+ key = "recheck_instance"
+ if column == "last_blocked":
+ key = "recheck_block"
+
# Query database
database.cursor.execute(f"SELECT {column} FROM instances WHERE domain = ? LIMIT 1", [domain])
# Fetch row
fetched = database.cursor.fetchone()[column]
- logger.debug("fetched[%s]='%s'", type(fetched), fetched)
- recently = isinstance(fetched, float) and (time.time() - fetched) <= config.get("recheck_instance")
+ logger.debug("fetched[%s]='%s',key='%s'", type(fetched), fetched, key)
+ recently = isinstance(fetched, float) and (time.time() - fetched) >= config.get(key)
logger.debug("recently='%s' - EXIT!", recently)
return recently