From 41a81639a9378013593a871c8bb2d4fdf65431dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 20 Nov 2023 01:45:15 +0100 Subject: [PATCH] Continued: - more named parameters - added some debug/warning lines --- fba/http/network.py | 5 ++--- fba/http/nodeinfo.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/fba/http/network.py b/fba/http/network.py index 3b5542e..1982957 100644 --- a/fba/http/network.py +++ b/fba/http/network.py @@ -210,6 +210,7 @@ def send_bot_post(domain: str, blocklist: list): truncated = False if len(blocklist) > 20: + logger.warning("blocklist()=%d for domain='%s' has more than 20 records, truncating to 20 ...", len(blocklist), domain) truncated = True blocklist = blocklist[0 : 19] @@ -268,12 +269,10 @@ def fetch_response(domain: str, path: str, headers: dict, timeout: tuple, allow_ allow_redirects=allow_redirects ) response_time = time.perf_counter() - start - logger.debug("response_time=%s", response_time) - + logger.debug("Setting response_time=%s for domain='%s' ...", response_time, domain) instances.set_last_response_time(domain, response_time) logger.debug("response.ok='%s',response.status_code=%d,response.reason='%s',response_time=%s", response.ok, response.status_code, response.reason, response_time) - except exceptions as exception: logger.debug("Fetching path='%s' from domain='%s' failed. exception[%s]='%s'", path, domain, type(exception), str(exception)) instances.set_last_error(domain, exception) diff --git a/fba/http/nodeinfo.py b/fba/http/nodeinfo.py index 5626812..341a15f 100644 --- a/fba/http/nodeinfo.py +++ b/fba/http/nodeinfo.py @@ -91,16 +91,21 @@ def fetch(domain: str, path: str = None, update_mode: bool = True) -> dict: data = network.get_json_api( domain, request, - headers, - (config.get("nodeinfo_connection_timeout"), config.get("nodeinfo_read_timeout")) + headers=headers, + timeout=(config.get("nodeinfo_connection_timeout"), config.get("nodeinfo_read_timeout")) ) logger.debug("data[]='%s'", type(data)) if "error_message" not in data and "json" in data: - logger.debug("Success: request='%s' - Setting detection_mode=STATIC_CHECK ...", request) + logger.debug("Updating last_nodeinfo for domain='%s' ....", domain) instances.set_last_nodeinfo(domain) + + logger.debug("update_mode='%s'", update_mode) if update_mode: + logger.debug("Success: request='%s' - Setting detection_mode=STATIC_CHECK for domain='%s' ...", request, domain) instances.set_detection_mode(domain, "STATIC_CHECK") + + logger.debug("domain='%s',request='%s'", domain, request) instances.set_nodeinfo_url(domain, "https://{domain}{request}") break -- 2.39.5