]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 11 Jun 2023 17:52:36 +0000 (19:52 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 11 Jun 2023 17:52:36 +0000 (19:52 +0200)
- logic fixed
- debug messages added

fba/networks/pleroma.py

index ade05924bbebd80d9691bee356d929eaa2550d87..8c16f884e95629a5c734cdb3fd75b797d9da792b 100644 (file)
@@ -99,7 +99,8 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                         # DEBUG: print(f"DEBUG: blocked='{blocked}' is blacklisted - skipping!")
                         continue
                     elif blocked.count("*") > 1:
-                        # -ACK!-oma also started obscuring domains without hash
+                        # Obsured domain name with no hash
+                        # DEBUG: print(f"DEBUG: Trying to de-obscure blocked='{blocked}' ...")
                         fba.cursor.execute(
                             "SELECT domain, nodeinfo_url FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", [blocked.replace("*", "_")]
                         )
@@ -110,18 +111,18 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                             print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!")
                             continue
 
+                        # DEBUG: print(f"DEBUG: blocked='{blocked}' de-obscured to '{searchres[0]}'")
                         blocked      = searchres[0]
                         nodeinfo_url = searchres[1]
-                        # DEBUG: print("DEBUG: Looked up domain:", blocked)
-                    elif not validators.domain(blocked):
+
+                    # DEBUG: print(f"DEBUG: blocked='{blocked}'")
+                    if not validators.domain(blocked):
                         print(f"WARNING: blocked='{blocked}',software='pleroma' is not a valid domain name - skipped!")
                         continue
                     elif blocked.split(".")[-1] == "arpa":
                         print(f"WARNING: blocked='{blocked}' is a reversed .arpa domain and should not be used generally.")
                         continue
-
-                    # DEBUG: print("DEBUG: Looking up instance by domain:", blocked)
-                    if not instances.is_registered(blocked):
+                    elif not instances.is_registered(blocked):
                         # Commit changes
                         fba.connection.commit()
 
@@ -181,14 +182,12 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                 if blocked == "":
                     print("WARNING: blocked is empty after tidyup.domain():", domain, block_level)
                     continue
-                elif not validators.domain(blocked):
-                    print(f"WARNING: blocked='{blocked}',software='pleroma' is not a valid domain name - skipped!")
-                    continue
                 elif blacklist.is_blacklisted(blocked):
                     # DEBUG: print(f"DEBUG: blocked='{blocked}' is blacklisted - skipping!")
                     continue
                 elif blocked.count("*") > 1:
-                    # same domain guess as above, but for reasons field
+                    # Obsured domain with no hash
+                    # DEBUG: print(f"DEBUG: Trying to de-obscure blocked='{blocked}' ...")
                     fba.cursor.execute(
                         "SELECT domain, origin, nodeinfo_url FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", [blocked.replace("*", "_")]
                     )
@@ -199,11 +198,15 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                         print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!")
                         continue
 
+                    # DEBUG: print(f"DEBUG: blocked='{blocked}' de-obscured to '{searchres[0]}'")
                     blocked = searchres[0]
                     origin = searchres[1]
                     nodeinfo_url = searchres[2]
+                elif not validators.domain(blocked):
+                    print(f"WARNING: blocked='{blocked}',software='pleroma' is not a valid domain name - skipped!")
+                    continue
 
-                # DEBUG: print("DEBUG: Looking up instance by domain:", blocked)
+                # DEBUG: print(f"DEBUG: blocked='{blocked}'")
                 if blocked.split(".")[-1] == "arpa":
                     print(f"WARNING: blocked='{blocked}' is a reversed .arpa domain and should not be used generally.")
                     continue