From 9f64a71ee243e082a32181d87dc447456e21b3ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 2 Jun 2023 19:51:58 +0200 Subject: [PATCH] Continued: - also rewrote this --- fetch_blocks.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/fetch_blocks.py b/fetch_blocks.py index d2649c0..86e5162 100755 --- a/fetch_blocks.py +++ b/fetch_blocks.py @@ -97,10 +97,14 @@ for blocker, software, origin, nodeinfo_url in rows: ) searchres = fba.cursor.fetchone() # DEBUG: print("DEBUG: searchres[]:", type(searchres)) - if searchres != None: - blocked = searchres[0] - nodeinfo_url = searchres[1] - # DEBUG: print("DEBUG: Looked up domain:", blocked) + + if searchres == None: + print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!") + continue + + blocked = searchres[0] + nodeinfo_url = searchres[1] + # DEBUG: print("DEBUG: Looked up domain:", blocked) elif not validators.domain(blocked): print(f"WARNING: blocked='{blocked}',software='{software}' is not a valid domai name - skipped!") continue @@ -175,10 +179,13 @@ for blocker, software, origin, nodeinfo_url in rows: ) searchres = fba.cursor.fetchone() - if searchres != None: - blocked = searchres[0] - origin = searchres[1] - nodeinfo_url = searchres[2] + if searchres == None: + print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!") + continue + + blocked = searchres[0] + origin = searchres[1] + nodeinfo_url = searchres[2] elif not validators.domain(blocked): print(f"WARNING: blocked='{blocked}',software='{software}' is not a valid domai name - skipped!") continue @@ -268,8 +275,8 @@ for blocker, software, origin, nodeinfo_url in rows: continue # DEBUG: print(f"DEBUG: Checking {len(blocks)} entries from blocker='{blocker}',software='{software}',block_level='{block_level}' ...") - for instance in blocks: - blocked, blocked_hash, reason = instance.values() + for block in blocks: + blocked, blocked_hash, reason = block.values() # DEBUG: print("DEBUG: blocked,hash,reason:", blocked, blocked_hash, reason) blocked = fba.tidyup(blocked) # DEBUG: print("DEBUG: AFTER-blocked:", blocked) @@ -288,7 +295,7 @@ for blocker, software, origin, nodeinfo_url in rows: searchres = fba.cursor.fetchone() if searchres == None: - print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!") + print(f"WARNING: Cannot deobsfucate blocked='{blocked}',blocked_hash='{blocked_hash}' - SKIPPED!") continue # DEBUG: print("DEBUG: Updating domain: ", searchres[0]) @@ -355,9 +362,11 @@ for blocker, software, origin, nodeinfo_url in rows: elif software == "bookwyrm": print("WARNING: bookwyrm is not fully supported for fetching blacklist!", blocker) #json = fba.get_bookwyrm_blocks(blocker) + continue elif software == "takahe": print("WARNING: takahe is not fully supported for fetching blacklist!", blocker) #json = fba.get_takahe_blocks(blocker) + continue print(f"INFO: Checking {len(json.items())} entries from blocker='{blocker}',software='{software}' ...") for block_level, blocks in json.items(): @@ -369,8 +378,8 @@ for blocker, software, origin, nodeinfo_url in rows: continue # DEBUG: print(f"DEBUG: Checking {len(blocks)} entries from blocker='{blocker}',software='{software}',block_level='{block_level}' ...") - for instance in blocks: - blocked, reason = instance.values() + for block in blocks: + blocked, reason = block.values() # DEBUG: print("DEBUG: BEFORE blocked:", blocked) blocked = fba.tidyup(blocked) # DEBUG: print("DEBUG: AFTER blocked:", blocked) -- 2.39.5