]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Fri, 19 Apr 2024 23:41:39 +0000 (01:41 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 19 Apr 2024 23:41:39 +0000 (01:41 +0200)
- recheck_obfuscation now supports deleting unwanted domains from both tables
  'instances' and 'blocks'

fba/boot.py
fba/commands.py
fba/models/blocks.py
fba/models/instances.py

index d87ef4d0075dfc03910a693f66ff86994c3ca739..daccf4de02dc29840e005a027ad2ad7157bcf6cb 100644 (file)
@@ -80,6 +80,7 @@ def init_parser():
     parser.add_argument("--domain", help="Instance name (aka. domain)")
     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")
 
     ### Fetch blocks from registered instances or given ###
     parser = subparser_command.add_parser(
index 87f9163003341bfd957a0876b02b10ed70f39796..e770b1c60942b67d9932aa93900efd42ce7e6f5f 100644 (file)
@@ -1326,8 +1326,15 @@ def recheck_obfuscation(args: argparse.Namespace) -> int:
     logger.info("Checking %d domains ...", len(rows))
     for row in rows:
         logger.debug("Fetching peers from domain='%s',software='%s',nodeinfo_url='%s' ...", row["domain"], row["software"], row["nodeinfo_url"])
-        if blacklist.is_blacklisted(row["domain"]):
-            logger.debug("row[domain]='%s' is blacklisted - SKIPPED!", row["domain"])
+        if not domain_helper.is_wanted(row["domain"]):
+            logger.debug("row[domain]='%s' is not wanted - SKIPPED!", row["domain"])
+            if args.delete_unwanted:
+                logger.info("Deleting unwanted row[domain]='%s' ...", row["domain"])
+                instances.delete(row["domain"])
+                blocks.delete(row["domain"])
+            continue
+        elif blacklist.is_blacklisted(row["domain"]):
+            logger.warning("row[domain]='%s' is blacklisted - SKIPPED!", row["domain"])
             continue
         elif (args.force is None or not args.force) and args.domain is None and args.software is None and instances.is_recent(row["domain"], "last_blocked"):
             logger.debug("row[domain]='%s' has recently been checked, args.force[]='%s' - SKIPPED!", row["domain"], type(args.force))
index 67828197b995838cc586a3653a409d53e5f7597a..66424c36ab0128e2cd025ddf177713ff55b550e5 100644 (file)
@@ -272,3 +272,15 @@ def alias_block_level(block_level: str) -> str:
 
     logger.debug("block_level='%s' - EXIT!", block_level)
     return block_level
+
+def delete(domain: str):
+    logger.debug("domain='%s' - CALLED!", domain)
+    domain_helper.raise_on(domain)
+
+    database.cursor.execute(f"DELETE FROM blocks WHERE blocker = ?", [domain])
+    database.cursor.execute(f"DELETE FROM blocks WHERE blocked = ?", [domain])
+
+    logger.debug("Invoking commit() ...")
+    database.connection.commit()
+
+    logger.debug("EXIT!")
index 72c16ba560bf8ffe2c0a3fbdcd092093279e0750..325be377998ab9e74a042ac8c8d9e0be4745a661 100644 (file)
@@ -573,6 +573,17 @@ def valid(value: str, column: str) -> bool:
     logger.debug("is_valid='%s' - EXIT!", is_valid)
     return is_valid
 
+def delete(domain: str):
+    logger.debug("domain='%s' - CALLED!", domain)
+    domain_helper.raise_on(domain)
+
+    database.cursor.execute(f"DELETE FROM instances WHERE domain = ? LIMIT 1", [domain])
+
+    logger.debug("Invoking commit() ...")
+    database.connection.commit()
+
+    logger.debug("EXIT!")
+
 def translate_idnas(rows: list, column: str):
     logger.debug("rows[]='%s' - CALLED!", type(rows))