From df78bc62ea3a57a5aa8b81ebaee1cf86e18c97e1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 30 May 2025 15:29:47 +0200 Subject: [PATCH] Continued: - let's not include original software in queries anymore when --software=xxx is provided - set software to None when --domain=xxx is provided (or --force-all/update-none) --- fba/commands.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fba/commands.py b/fba/commands.py index 3f0c5d5..bdebbfe 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -296,7 +296,7 @@ def fetch_blocks(args: argparse.Namespace) -> int: elif args.software not in [None, ""]: # Re-check single software logger.debug("Querying database for args.software='%s' ...", args.software) - database.cursor.execute("SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software = ? OR original_software = ? ORDER BY last_blocked ASC, total_blocks DESC", [args.software, args.software]) + database.cursor.execute("SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software = ? ORDER BY last_blocked ASC, total_blocks DESC", [args.software]) elif args.only_none: # Check only entries with total_blocked=None logger.debug("Checking only entries with total_blocked=None ...") @@ -1342,7 +1342,7 @@ def recheck_obfuscation(args: argparse.Namespace) -> int: database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE domain = ? LIMIT 1", [args.domain]) elif isinstance(args.software, str) and args.software != "" and validators.domain(args.software, rfc_2782=True) == args.software: logger.debug("Fetching records for args.software='%s' ...", args.software) - database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE (has_obfuscation = 1 OR has_obfuscation IS NULL) AND software = ? OR original_software = ? ORDER BY last_blocked ASC", [args.software, args.software]) + database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE (has_obfuscation = 1 OR has_obfuscation IS NULL) AND software = ? ORDER BY last_blocked ASC", [args.software]) elif args.no_obfuscation: logger.debug("Fetching records with no obfuscation of blocked domain ...") database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE has_obfuscation = 0 AND total_blocks > 0 AND software IS NOT NULL ORDER BY last_blocked ASC") @@ -1552,7 +1552,7 @@ def update_nodeinfo(args: argparse.Namespace) -> int: database.cursor.execute("SELECT domain, software FROM instances WHERE domain = ? LIMIT 1", [args.domain]) elif args.software not in [None, ""]: logger.info("Fetching domains for args.software='%s'", args.software) - database.cursor.execute("SELECT domain, software FROM instances WHERE software = ? OR original_software = ? ORDER BY last_updated ASC", [args.software, args.software]) + database.cursor.execute("SELECT domain, software FROM instances WHERE software = ? ORDER BY last_updated ASC", [args.software]) elif args.mode not in [None, ""]: logger.info("Fetching domains for args.mode='%s'", args.mode.upper()) database.cursor.execute("SELECT domain, software FROM instances WHERE detection_mode = ? ORDER BY last_updated ASC", [args.mode]) @@ -1620,6 +1620,11 @@ def update_nodeinfo(args: argparse.Namespace) -> int: logger.warning("Exception '%s' during updating nodeinfo for row[domain]='%s'", type(exception), row["domain"]) instances.set_last_error(row["domain"], exception) + logger.debug("args.domain='%s',args.force_all='%s',args.force_update_none='%s'", args.domain, args.force_all, args.force_update_none) + if args.domain not in [None, ""] or args.force_all is True or args.force_update_none is True: + logger.debug("Setting software=None for row[domain]='%s' ...", row["domain"]) + instances.set_software(row["domain"], None) + logger.debug("Updating instanes for row[domain]='%s' ...", row["domain"]) instances.set_last_nodeinfo(row["domain"]) instances.update(row["domain"]) -- 2.39.5