From: Roland Häder Date: Mon, 12 Jun 2023 10:38:53 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=50d98fa985cade0ca390658c0f61e660f3548392;p=fba.git Continued: - tpzo fixed in function name - also re-check with domain if hash wasn't found - 'runtube.re' aliased to 'peertube' --- diff --git a/fba/commands.py b/fba/commands.py index 96018e9..07db1af 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -210,7 +210,7 @@ def fetch_blocks(args: argparse.Namespace): continue elif blocked.count("*") > 0: # Some friendica servers also obscure domains without hash - row = instances.deobsure("*", blocked) + row = instances.deobscure("*", blocked) # DEBUG: print(f"DEBUG: row[]='{type(row)}'") if row is None: @@ -222,7 +222,7 @@ def fetch_blocks(args: argparse.Namespace): nodeinfo_url = row[2] elif blocked.count("?") > 0: # Some obscure them with question marks, not sure if that's dependent on version or not - row = instances.deobsure("?", blocked) + row = instances.deobscure("?", blocked) # DEBUG: print(f"DEBUG: row[]='{type(row)}'") if row is None: @@ -553,8 +553,8 @@ def fetch_oliphant(args: argparse.Namespace): continue if domain.find("*") > 0: - # Try to de-obsure it - row = instances.deobsure("*", domain) + # Try to de-obscure it + row = instances.deobscure("*", domain) # DEBUG: print(f"DEBUG: row[{type(row)}]='{row}'") if row is None: diff --git a/fba/federation.py b/fba/federation.py index 80d7a71..549f8a2 100644 --- a/fba/federation.py +++ b/fba/federation.py @@ -426,6 +426,9 @@ def determine_software(domain: str, path: str = None) -> str: elif software in ["calckey", "groundpolis", "foundkey", "cherrypick", "meisskey"]: # DEBUG: print("DEBUG: Setting misskey:", domain, software) software = "misskey" + elif software == "runtube.re": + # DEBUG: print("DEBUG: Setting peertube:", domain, software) + software = "peertube" elif software.find("/") > 0: print("WARNING: Spliting of slash:", software) software = tidyup.domain(software.split("/")[-1]) diff --git a/fba/instances.py b/fba/instances.py index 4cccb37..aa912e0 100644 --- a/fba/instances.py +++ b/fba/instances.py @@ -337,7 +337,7 @@ def is_recent(domain: str) -> bool: # DEBUG: print(f"DEBUG: recently='{recently}' - EXIT!") return recently -def deobsure(char: str, domain: str, blocked_hash: str = None) -> tuple: +def deobscure(char: str, domain: str, blocked_hash: str = None) -> tuple: #print(f"DEBUG: char='{char}',domain='{domain}',blocked_hash='{blocked_hash}' - CALLED!") if not isinstance(char, str): raise ValueError(f"Parameter char[]='{type(char)}' is not 'str'") @@ -354,6 +354,10 @@ def deobsure(char: str, domain: str, blocked_hash: str = None) -> tuple: fba.cursor.execute( "SELECT domain, origin, nodeinfo_url FROM instances WHERE hash = ? LIMIT 1", [blocked_hash] ) + + if fba.cursor.fetchone() is None: + #print(f"DEBUG: blocked_hash='{blocked_hash}' not found, trying domain='{domain}' ...") + return deobscure(char, domain) else: fba.cursor.execute( "SELECT domain, origin, nodeinfo_url FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", [domain.replace(char, "_")] diff --git a/fba/networks/mastodon.py b/fba/networks/mastodon.py index ae5ea0c..ef580fb 100644 --- a/fba/networks/mastodon.py +++ b/fba/networks/mastodon.py @@ -242,7 +242,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str): continue elif blocked.count("*") > 0: # Doing the hash search for instance names as well to tidy up DB - row = instances.deobsure("*", blocked, blocked_hash) + row = instances.deobscure("*", blocked, blocked_hash) # DEBUG: print(f"DEBUG: row[]='{type(row)}'") if row is None: diff --git a/fba/networks/pleroma.py b/fba/networks/pleroma.py index f970147..be7a840 100644 --- a/fba/networks/pleroma.py +++ b/fba/networks/pleroma.py @@ -96,8 +96,8 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str): # DEBUG: print(f"DEBUG: blocked='{blocked}' is blacklisted - skipping!") continue elif blocked.count("*") > 0: - # Obsured domain name with no hash - row = instances.deobsure("*", blocked) + # Obscured domain name with no hash + row = instances.deobscure("*", blocked) # DEBUG: print(f"DEBUG: row[]='{type(row)}'") if row is None: @@ -180,8 +180,8 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str): # DEBUG: print(f"DEBUG: blocked='{blocked}' is blacklisted - skipping!") continue elif blocked.count("*") > 0: - # Obsured domain name with no hash - row = instances.deobsure("*", blocked) + # Obscured domain name with no hash + row = instances.deobscure("*", blocked) # DEBUG: print(f"DEBUG: row[]='{type(row)}'") if row is None: