from fba.helpers import cache
from fba.helpers import config
from fba.helpers import domain as domain_helper
+from fba.helpers import tidyup
from fba.http import federation
from fba.http import network
elif not isinstance(blocked_hash, str) and blocked_hash is not None:
raise ValueError(f"Parameter blocked_hash[]='{type(blocked_hash)}' is not 'str'")
+ # Init row
+ row = None
+
logger.debug("blocked_hash[]='%s'", type(blocked_hash))
if isinstance(blocked_hash, str):
logger.debug("Looking up blocked_hash='%s',domain='%s' ...", blocked_hash, domain)
if row is None:
logger.debug("blocked_hash='%s' not found, trying domain='%s' ...", blocked_hash, domain)
return deobfuscate(char, domain)
- else:
- logger.debug("Looking up domain='%s' ...", domain)
+ elif not domain.startswith("*."):
+ logger.debug("domain='%s' - BEFORE!", domain)
+ domain = tidyup.domain(domain)
+ logger.debug("domain='%s' - AFTER!", domain)
+
+ if domain == "":
+ debug.warning("domain is empty after tidyup - EXIT!")
+ return None
+
+ search = domain.replace(char, "_")
+
+ logger.debug("Looking up domain='%s',search='%s' ...", domain, search)
database.cursor.execute(
- "SELECT domain, origin, nodeinfo_url FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", [domain.replace(char, "_")]
+ "SELECT domain, origin, nodeinfo_url FROM instances WHERE domain LIKE ? OR 'https://' || domain LIKE ? ORDER BY rowid LIMIT 1", [search, search]
)
row = database.cursor.fetchone()