From df17e9049d439f3a0769f6970302266157ecdf90 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 4 Jul 2023 16:49:13 +0200 Subject: [PATCH] Continued: - try to "crawl" instances being redirected to --- fba/http/federation.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fba/http/federation.py b/fba/http/federation.py index c7c2fd8..845d46a 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -448,11 +448,20 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str: instances.set_detection_mode(domain, "PLATFORM") elif not domain_helper.is_in_url(domain, response.url): logger.warning("domain='%s' doesn't match response.url='%s', maybe redirect to other domain?", domain, response.url) + + components = urlparse(response.url) + + log.debug("components[]='%s'", type(components)) + if not instances.is_registered(components.netloc): + logger.info("components.netloc='%s' is not registered, adding ...", components.netloc) + fetch_instances(components.netloc, domain, None, "fetch_generator") + message = f"Redirect from domain='{domain}' to response.url='{response.url}'" instances.set_last_error(domain, message) instances.set_software(domain, None) instances.set_detection_mode(domain, None) instances.set_nodeinfo_url(domain, None) + raise requests.exceptions.TooManyRedirects(message) logger.debug("software[]='%s'", type(software)) -- 2.39.5