From 970c8a81359c60713df79d8dc4adc6b1ae14f917 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 21 Nov 2023 17:23:41 +0100 Subject: [PATCH] Continued: - added last_response_time to templates - moved cookie clearing to proper place (?) --- daemon.py | 2 +- fba/http/federation.py | 17 ++++++++++------- templates/views/infos.html | 5 +++++ templates/views/list.html | 2 ++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/daemon.py b/daemon.py index ff68610..5ee0181 100755 --- a/daemon.py +++ b/daemon.py @@ -447,7 +447,7 @@ def infos(request: Request, domain: str): tformat = config.get("timestamp_format") instance = dict() for key in domain_data.keys(): - if key in ["last_nodeinfo", "last_blocked", "first_seen", "last_updated", "last_instance_fetch", "last_response_time"] and isinstance(domain_data[key], float): + if key in ["last_nodeinfo", "last_blocked", "first_seen", "last_updated", "last_instance_fetch" and isinstance(domain_data[key], float): # Timestamps instance[key] = datetime.utcfromtimestamp(domain_data[key]).strftime(tformat) else: diff --git a/fba/http/federation.py b/fba/http/federation.py index 0fd5720..c17e52d 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -107,6 +107,9 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: logger.debug("Invoking instances.set_total_peerlist(%s,%d) ...", domain, len(peerlist)) instances.set_total_peers(domain, peerlist) + logger.debug("Invoking cookies.clear(%s) ...", domain) + cookies.clear(domain) + logger.debug("peerlist[]='%s'", type(peerlist)) if peerlist is None: logger.warning("Cannot fetch peers: domain='%s',software='%s'", domain, software) @@ -115,15 +118,18 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: logger.debug("Flushing updates for domain='%s' ...", domain) instances.update(domain) - logger.debug("Invoking cookies.clear(%s) ...", domain) - cookies.clear(domain) - _DEPTH = _DEPTH - 1 logger.debug("EXIT!") return elif len(peerlist) == 0: - logger.debug("domain='%s',software='%s' has an empty peer list returned - EXIT!", domain, software) + logger.info("domain='%s' returned an empty peer list.", domain) + + if instances.has_pending(domain): + logger.debug("Flushing updates for domain='%s' ...", domain) + instances.update(domain) + _DEPTH = _DEPTH - 1 + logger.debug("domain='%s',software='%s' has an empty peer list returned - EXIT!", domain, software) return logger.info("Checking %d instance(s) from domain='%s',software='%s',depth=%d ...", len(peerlist), domain, software, _DEPTH) @@ -171,9 +177,6 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: logger.debug("Adding instance='%s',domain='%s',command='%s',_DEPTH=%d ...", instance, domain, command, _DEPTH) instances.add(instance, domain, command) - logger.debug("Invoking cookies.clear(%s) ...", domain) - cookies.clear(domain) - logger.debug("Checking if domain='%s' has pending updates ...", domain) if instances.has_pending(domain): logger.debug("Flushing updates for domain='%s' ...", domain) diff --git a/templates/views/infos.html b/templates/views/infos.html index 0eb57d8..274360f 100644 --- a/templates/views/infos.html +++ b/templates/views/infos.html @@ -80,6 +80,11 @@ {{instance['total_blocks']}} + + Last response time: + {{'%0.2f'|format(instance['last_response_time']|float)}} + + Obfuscated blocks: {{instance['obfuscated_blocks']}} diff --git a/templates/views/list.html b/templates/views/list.html index 1f5ff96..1e48ebd 100644 --- a/templates/views/list.html +++ b/templates/views/list.html @@ -44,6 +44,7 @@ Command Total peers Total blocks + Response time First added Last updated @@ -74,6 +75,7 @@ {{row['command']}} {{row['total_peers']}} {{row['total_blocks']}} + {{'%0.2f'|format(row['last_response_time']|float)}} {{row['first_seen']}} {{row['last_updated']}} -- 2.39.5