From 649cbde73fc3c56945211c3e7c551dd6db41afe9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 8 Jul 2023 23:22:23 +0200 Subject: [PATCH] Continued: - some instances or honeypots may return empty (None in Python) link[href] entries - you can run a honeypot and pay monthly domain fees for it, not my business, but at least format your /.well-known/nodeinfo properly! --- fba/http/federation.py | 10 +++++++--- fba/models/instances.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fba/http/federation.py b/fba/http/federation.py index 74edbd7..8cc5905 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -347,11 +347,14 @@ def fetch_wellknown_nodeinfo(domain: str) -> dict: elif "href" not in link: logger.warning("link[rel]='%s' has no element 'href' - SKIPPED!", link["rel"]) continue + elif link["href"] is None: + logger.debug("link[href] is None, link[rel]='%s' - SKIPPED!", link["rel"]) + continue # Default is that 'href' has a complete URL, but some hosts don't send that logger.debug("link[rel]='%s' matches niid='%s'", link["rel"], niid) url = link["href"] - components = urlparse(link["href"]) + components = urlparse(url) logger.debug("components[%s]='%s'", type(components), components) if components.scheme == "" and components.netloc == "": @@ -363,6 +366,7 @@ def fetch_wellknown_nodeinfo(domain: str) -> dict: url = f"{components.scheme}://{domain}{components.path}" components = urlparse(url) + logger.debug("components.netloc[]='%s'", type(components.netloc)) if not utils.is_domain_wanted(components.netloc): logger.debug("components.netloc='%s' is not wanted - SKIPPED!", components.netloc) continue @@ -397,7 +401,7 @@ def fetch_wellknown_nodeinfo(domain: str) -> dict: return data def fetch_generator_from_path(domain: str, path: str = "/") -> str: - logger.debug("domain(%d)='%s',path='%s' - CALLED!", len(domain), domain, path) + logger.debug("domain='%s',path='%s' - CALLED!", domain, path) domain_helper.raise_on(domain) if not isinstance(path, str): @@ -495,7 +499,7 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str: return software def determine_software(domain: str, path: str = None) -> str: - logger.debug("domain(%d)='%s',path='%s' - CALLED!", len(domain), domain, path) + logger.debug("domain='%s',path='%s' - CALLED!", domain, path) domain_helper.raise_on(domain) if not isinstance(path, str) and path is not None: diff --git a/fba/models/instances.py b/fba/models/instances.py index 3c8433d..7968ff2 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -431,7 +431,7 @@ def set_detection_mode(domain: str, mode: str): logger.debug("EXIT!") def set_has_obfuscation(domain: str, status: bool): - logger.debug("domain(%d)='%s',status='%s' - CALLED!", len(domain), domain, status) + logger.debug("domain='%s',status='%s' - CALLED!", domain, status) domain_helper.raise_on(domain) if not isinstance(status, bool): -- 2.39.5