From: Roland Häder Date: Mon, 2 Oct 2023 07:56:43 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8c5ede5559e4019f1dfd2a9d6d864e53215a0ee4;p=fba.git Continued: - ordered SELECT statement for update_nodeinfo() command - added --no-auto as another "filter" parameter - don't check domains that turn e.g. into an IP address before redirecting to them --- diff --git a/fba/boot.py b/fba/boot.py index 67974d9..6b90614 100644 --- a/fba/boot.py +++ b/fba/boot.py @@ -217,6 +217,7 @@ def init_parser(): parser.add_argument("--mode", help="Name of detection mode, e.g. 'auto_discovery'") parser.add_argument("--force", action="store_true", help="Forces update of data, no matter what.") parser.add_argument("--no-software", action="store_true", help="Checks only entries with no software type detected.") + parser.add_argument("--no-auto", action="store_true", help="Checks only entries with other than AUTO_DISCOVERY as detection mode.") ### Fetch instances from instances.social ### parser = subparser_command.add_parser( diff --git a/fba/commands.py b/fba/commands.py index ad84515..f7165d6 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -1460,19 +1460,22 @@ def update_nodeinfo(args: argparse.Namespace) -> int: if args.domain is not None and args.domain != "": logger.debug("Fetching args.domain='%s'", args.domain) - database.cursor.execute("SELECT domain, software FROM instances WHERE domain = ?", [args.domain]) + database.cursor.execute("SELECT domain, software FROM instances WHERE domain = ? LIMIT 1", [args.domain]) elif args.software is not None and args.software != "": logger.info("Fetching domains for args.software='%s'", args.software) - database.cursor.execute("SELECT domain, software FROM instances WHERE software = ? AND (last_nodeinfo < ? OR last_nodeinfo IS NULL)", [args.software.lower(), time.time() - config.get("recheck_nodeinfo")]) + database.cursor.execute("SELECT domain, software FROM instances WHERE software = ? ORDER BY last_updated ASC") elif args.mode is not None and args.mode != "": logger.info("Fetching domains for args.mode='%s'", args.mode.upper()) - database.cursor.execute("SELECT domain, software FROM instances WHERE detection_mode = ? AND (last_nodeinfo < ? OR last_nodeinfo IS NULL)", [args.mode.upper(), time.time() - config.get("recheck_nodeinfo")]) + database.cursor.execute("SELECT domain, software FROM instances WHERE detection_mode = ? ORDER BY last_updated ASC") elif args.no_software: logger.info("Fetching domains with no software type detected ...") - database.cursor.execute("SELECT domain, software FROM instances WHERE software IS NULL AND (last_nodeinfo < ? OR last_nodeinfo IS NULL)", [time.time() - config.get("recheck_nodeinfo")]) + database.cursor.execute("SELECT domain, software FROM instances WHERE software IS NULL ORDER BY last_updated ASC") + elif args.no_auto: + logger.info("Fetching domains with other detection mode than AUTO_DISOVERY being set ...") + database.cursor.execute("SELECT domain, software FROM instances WHERE detection_mode IS NOT NULL AND detection_mode != 'AUTO_DISCOVERY' ORDER BY last_updated ASC") else: logger.info("Fetching domains for recently updated ...") - database.cursor.execute("SELECT domain, software FROM instances WHERE last_nodeinfo < ? OR last_nodeinfo IS NULL", [time.time() - config.get("recheck_nodeinfo")]) + database.cursor.execute("SELECT domain, software FROM instances ORDER BY last_updated ASC") domains = database.cursor.fetchall() diff --git a/fba/http/federation.py b/fba/http/federation.py index 5fb9608..2156690 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -320,7 +320,10 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str: domain2 = components.netloc.lower().split(":")[0] logger.debug("domain2='%s'", domain2) - if not instances.is_registered(domain2): + if not domain_helper.is_wanted(domain2): + logger.debug("domain2='%s' is not wanted - EXIT!", domain2) + return None + elif not instances.is_registered(domain2): logger.info("components.netloc='%s' is not registered, adding ...", components.netloc) fetch_instances(domain2, domain, None, "redirect_target") diff --git a/nodeinfo.sh b/nodeinfo.sh index 16baaee..4084a9b 100755 --- a/nodeinfo.sh +++ b/nodeinfo.sh @@ -6,7 +6,7 @@ SOFTWARE_LIST="" if [ "$1" = "--help" ] then - echo "Usage: $0 [file|--software|--software2|--software3|--nodeinfo|--generator|--detection|--no-auto|--no-auto2|--timeout]" + echo "Usage: $0 [file|--software|--software2|--software3|--nodeinfo|--generator|--detection|--no-auto|--timeout]" exit 255 elif [ -n "$1" -a -f "$1" ] then @@ -25,10 +25,6 @@ then DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE detection_mode IS NULL ORDER BY last_updated ASC;") MODE="detection" elif [ "$1" = "--no-auto" ] -then - DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE detection_mode IS NOT NULL AND detection_mode != 'AUTO_DISCOVERY' ORDER BY last_updated ASC;") - MODE="noauto" -elif [ "$1" = "--no-auto2" ] then DOMAINS=`sqlite3 blocks.db "SELECT domain FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey', 'peertube', 'takahe', 'gotosocial', 'brighteon', 'wildebeest', 'bookwyrm', 'mitra', 'areionskey', 'mammuthus') AND detection_mode != 'AUTO_DISCOVERY' ORDER BY last_updated ASC;"` MODE="noauto2"