From 97cfc1fc1f63bcc4f4ef68e9473233f9626f0336 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 23 Jun 2023 06:33:13 +0200 Subject: [PATCH] Continued: - used more `foo in ['some', 'other']` --- fba/http/federation.py | 12 ++++++++---- fba/models/instances.py | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/fba/http/federation.py b/fba/http/federation.py index a27bedc..ad24959 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -222,10 +222,14 @@ def fetch_nodeinfo(domain: str, path: str = None) -> dict: ] for request in request_paths: - logger.debug("path[%s]='%s',request='%s'", type(path), path, request) - if path is None or path == request or path == f"http://{domain}{path}" or path == f"https://{domain}{path}": + logger.debug("request='%s'", request) + http_url = f"http://{domain}{path}" + https_url = f"https://{domain}{path}" + + logger.debug("path[%s]='%s',request='%s',http_url='%s',https_url='%s'", type(path), path, request, http_url, https_url) + if path is None or path in [request, http_url, https_url]: logger.debug("Fetching request='%s' from domain='%s' ...", request, domain) - if path in [f"http://{domain}{path}", f"https://{domain}{path}"]: + if path in [http_url, https_url]: logger.debug("domain='%s',path='%s' has protocol in path, splitting ...", domain, path) components = urlparse(path) path = components.path @@ -238,7 +242,7 @@ def fetch_nodeinfo(domain: str, path: str = None) -> dict: ) logger.debug("data[]='%s'", type(data)) - if "error_message" not in data: + if "error_message" not in data and "json" in data: logger.debug("Success: request='%s'", request) instances.set_detection_mode(domain, "STATIC_CHECK") instances.set_nodeinfo_url(domain, request) diff --git a/fba/models/instances.py b/fba/models/instances.py index fe2c1b0..3ba561f 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -41,7 +41,7 @@ logger = logging.getLogger(__name__) # written to database. Both arrays must be filled at the same time or else # update_data() will fail _pending = { - # Detection mode: 'AUTO_DISCOVERY', 'STATIC_CHECKS' or 'GENERATOR' + # Detection mode # NULL means all detection methods have failed (maybe still reachable instance) "detection_mode" : {}, # Found nodeinfo URL -- 2.39.5