diff --git a/fediseer/apis/v1/base.py b/fediseer/apis/v1/base.py index abd599b..2a9ec25 100644 --- a/fediseer/apis/v1/base.py +++ b/fediseer/apis/v1/base.py @@ -60,7 +60,7 @@ class Suspicions(Resource): -def ensure_instance_registered(domain): +def ensure_instance_registered(domain, allow_unreachable=False): if domain.endswith("test.dbzer0.com"): # Fake instances for testing chain of trust requested_lemmy = Lemmy(f"https://{domain}") @@ -75,7 +75,18 @@ def ensure_instance_registered(domain): else: nodeinfo = get_nodeinfo(domain) if not nodeinfo: - raise e.BadRequest(f"Error encountered while polling domain {domain}. Please check it's running correctly") + if not allow_unreachable: + raise e.BadRequest(f"Error encountered while polling domain {domain}. Please check it's running correctly") + else: + software = "unknown" + if "*" in domain: + software = "wildcard" + nodeinfo = { + "openRegistrations": False, + "software": { + "name": software + } + } software = nodeinfo["software"]["name"] if software == "lemmy": requested_lemmy = Lemmy(f"https://{domain}") diff --git a/fediseer/apis/v1/censures.py b/fediseer/apis/v1/censures.py index 066a655..63c697c 100644 --- a/fediseer/apis/v1/censures.py +++ b/fediseer/apis/v1/censures.py @@ -95,7 +95,7 @@ class Censures(Resource): unbroken_chain, chainbreaker = database.has_unbroken_chain(instance.id) if not unbroken_chain: raise e.Forbidden(f"Guarantee chain for this instance has been broken. Chain ends at {chainbreaker.domain}!") - target_instance, nodeinfo, admin_usernames = ensure_instance_registered(domain) + target_instance, nodeinfo, admin_usernames = ensure_instance_registered(domain, allow_unreachable=True) if not target_instance: raise e.NotFound(f"Something went wrong trying to register this instance.") if not target_instance: diff --git a/fediseer/fediverse.py b/fediseer/fediverse.py index ad41294..6f9f7e8 100644 --- a/fediseer/fediverse.py +++ b/fediseer/fediverse.py @@ -8,7 +8,7 @@ def get_lemmy_admins(domain): site = requested_lemmy.site.get() if not site: logger.warning(f"Error retrieving mastodon site info for {domain}") - return None + raise Exception(f"Error retrieving mastodon site info for {domain}") return [a["person"]["name"] for a in site["admins"]] def get_mastodon_admins(domain): @@ -17,13 +17,18 @@ def get_mastodon_admins(domain): return [site["contact"]["account"]["username"]] except Exception as err: logger.warning(f"Error retrieving mastodon site info for {domain}: {err}") - return None + raise Exception(f"Error retrieving mastodon site info for {domain}: {err}") + +def get_unknown_admins(domain): + return [] def get_admin_for_software(software: str, domain: str): software_map = { "lemmy": get_lemmy_admins, "mastodon": get_mastodon_admins, "friendica": get_mastodon_admins, + "unknown": get_unknown_admins, + "wildcard": get_unknown_admins, } if software not in software_map: return []