From: Roland Häder Date: Thu, 25 Jul 2024 21:24:12 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d1c5dab8cf433d09bb8ad3d36b15633857d8de41;p=fba.git Continued: - added parameter --no-obfuscation to recheck records where blocked domains are not obfuscated before but maybe now and still have a software detected - sort those recheck lists by last_blocked --- diff --git a/fba/boot.py b/fba/boot.py index daccf4d..c66b2ac 100644 --- a/fba/boot.py +++ b/fba/boot.py @@ -81,6 +81,7 @@ def init_parser(): parser.add_argument("--software", help="Name of software, e.g. 'lemmy'") parser.add_argument("--force", action="store_true", help="Include also already existing instances, otherwise only new are checked") parser.add_argument("--delete-unwanted", action="store_true", help="Whether delete or keep (default) unwanted domains") + parser.add_argument("--no-obfuscation", action="store_true", help="Check instances with no obfuscation of blocked instances") ### Fetch blocks from registered instances or given ### parser = subparser_command.add_parser( diff --git a/fba/commands.py b/fba/commands.py index f97ad8f..b845499 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -1341,13 +1341,16 @@ def recheck_obfuscation(args: argparse.Namespace) -> int: if isinstance(args.domain, str) and args.domain != "" and domain_helper.is_wanted(args.domain): logger.debug("Fetching record for args.domain='%s' ...", args.domain) - database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE (has_obfuscation = 1 OR has_obfuscation IS NULL) AND domain = ?", [args.domain]) + database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE (has_obfuscation = 1 OR has_obfuscation IS NULL) AND domain = ? ORDER BY last_blocked ASC", [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 = ?", [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") else: logger.debug("Fetching records where domains have obfuscated block entries ...") - database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE has_obfuscation = 1 OR has_obfuscation IS NULL") + database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE has_obfuscation = 1 OR has_obfuscation IS NULL ORDER BY last_blocked ASC") rows = database.cursor.fetchall() logger.info("Checking %d domains ...", len(rows))