]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 3 Oct 2023 13:24:57 +0000 (15:24 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 3 Oct 2023 13:24:57 +0000 (15:24 +0200)
- change has_obfuscation when detected, not when a domain wasn't deobfuscated
- also count de-/obfuscated domains

fba/commands.py

index f7165d6d2b5343140adb80725ec877b7c2651aec..ea96bf8a83c3475b00b3f3ec01a5862c4bc1313d 100644 (file)
@@ -350,6 +350,7 @@ def fetch_blocks(args: argparse.Namespace) -> int:
         instances.set_total_blocks(blocker, blocking)
 
         blockdict = list()
+        deobfuscated = obfuscated = 0
 
         logger.info("Checking %d entries from blocker='%s',software='%s' ...", len(blocking), blocker, software)
         for block in blocking:
@@ -378,6 +379,8 @@ def fetch_blocks(args: argparse.Namespace) -> int:
                 continue
             elif block["blocked"].find("*") >= 0:
                 logger.debug("blocker='%s' uses obfuscated domains", blocker)
+                instances.set_has_obfuscation(blocker, True)
+                obfuscated = obfuscated + 1
 
                 # Some friendica servers also obscure domains without hash
                 row = instances.deobfuscate("*", block["blocked"], block["hash"] if "hash" in block else None)
@@ -385,14 +388,16 @@ def fetch_blocks(args: argparse.Namespace) -> int:
                 logger.debug("row[]='%s'", type(row))
                 if row is None:
                     logger.warning("Cannot deobfuscate blocked='%s',blocker='%s',software='%s' - SKIPPED!", block["blocked"], blocker, software)
-                    instances.set_has_obfuscation(blocker, True)
                     continue
 
+                deobfuscated = deobfuscated + 1
                 block["blocked"] = row["domain"]
                 origin           = row["origin"]
                 nodeinfo_url     = row["nodeinfo_url"]
             elif block["blocked"].find("?") >= 0:
                 logger.debug("blocker='%s' uses obfuscated domains", blocker)
+                instances.set_has_obfuscation(blocker, True)
+                obfuscated = obfuscated + 1
 
                 # Some obscure them with question marks, not sure if that's dependent on version or not
                 row = instances.deobfuscate("?", block["blocked"], block["hash"] if "hash" in block else None)
@@ -400,9 +405,9 @@ def fetch_blocks(args: argparse.Namespace) -> int:
                 logger.debug("row[]='%s'", type(row))
                 if row is None:
                     logger.warning("Cannot deobfuscate blocked='%s',blocker='%s',software='%s' - SKIPPED!", block["blocked"], blocker, software)
-                    instances.set_has_obfuscation(blocker, True)
                     continue
 
+                deobfuscated = deobfuscated + 1
                 block["blocked"] = row["domain"]
                 origin           = row["origin"]
                 nodeinfo_url     = row["nodeinfo_url"]
@@ -438,6 +443,8 @@ def fetch_blocks(args: argparse.Namespace) -> int:
             logger.debug("Invoking cookies.clear(%s) ...", block["blocked"])
             cookies.clear(block["blocked"])
 
+        logger.info("blocker='%s' has %d obfuscated domain(s) and %d of them could be deobfuscated.", block["blocker"], obfuscated, deobfuscated)
+
         logger.debug("Checking if blocker='%s' has pending updates ...", blocker)
         if instances.has_pending(blocker):
             logger.debug("Flushing updates for blocker='%s' ...", blocker)