From: Roland Häder Date: Sat, 25 Nov 2023 23:45:04 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e0fced66d6da02e47df31c87b4bcf08797bdf059;p=fba.git Continued: - improved/added debug lines --- diff --git a/fba/networks/misskey.py b/fba/networks/misskey.py index e318cd6..ddbfa46 100644 --- a/fba/networks/misskey.py +++ b/fba/networks/misskey.py @@ -141,7 +141,7 @@ def fetch_blocks(domain: str) -> list: headers = tuple() try: - logger.debug("Checking CSRF for domain='%s'", domain) + logger.debug("Checking CSRF for domain='%s' ...", domain) headers = csrf.determine(domain, dict()) except network.exceptions as exception: logger.warning("Exception '%s' during checking CSRF (fetch_blocks,%s)", type(exception), __name__) @@ -158,6 +158,7 @@ def fetch_blocks(domain: str) -> list: # instances page-by-page since it doesn't support sending them all at once logger.debug("Fetching misskey blocks from domain='%s'", domain) while True: + logger.debug("offset=%d", offset) try: logger.debug("Fetching offset=%d from domain='%s' ...", offset, domain) if offset == 0: @@ -202,6 +203,7 @@ def fetch_blocks(domain: str) -> list: offset = offset + step count = 0 + logger.debug("Checking %d row(s) of instances ...", len(rows)) for instance in rows: # Is it there? logger.debug("instance[]='%s'", type(instance)) @@ -245,6 +247,7 @@ def fetch_blocks(domain: str) -> list: while True: # Fetch blocked (full suspended) instances + logger.debug("offset=%d", offset) try: if offset == 0: logger.debug("Sending JSON API request to domain='%s',step=%d,offset=%d", domain, step, offset) @@ -288,12 +291,13 @@ def fetch_blocks(domain: str) -> list: offset = offset + step count = 0 + logger.debug("Checking %d row(s) of instances ...", len(rows)) for instance in rows: # Is it there? logger.debug("instance[]='%s'", type(instance)) blocked = tidyup.domain(instance["host"]) - logger.debug("blocked='%s'", blocked) + if blocked is None or blocked == "": logger.warning("instance[host]='%s' is None or empty after tidyup.domain() - SKIPPED!", instance["host"]) continue diff --git a/fba/networks/pleroma.py b/fba/networks/pleroma.py index e26cabe..41d8500 100644 --- a/fba/networks/pleroma.py +++ b/fba/networks/pleroma.py @@ -124,40 +124,40 @@ def fetch_blocks(domain: str) -> list: block_level = blocks.alias_block_level(block_level) logger.debug("Checking %d entries from domain='%s',block_level='%s' ...", len(blocklist), domain, block_level) - if len(blocklist) > 0: - for blocked in blocklist: - logger.debug("blocked='%s' - BEFORE!", blocked) - blocked = tidyup.domain(blocked) if blocked != "" else None - logger.debug("blocked='%s' - AFTER!", blocked) - - if blocked is None or blocked == "": - logger.warning("blocked='%s' is empty after tidyup.domain(): domain='%s',block_level='%s' - SKIPPED!", blocked, domain, block_level) - continue - - logger.debug("Invoking utils.deobfuscate(%s, %s) ...", blocked, domain) - blocked = utils.deobfuscate(blocked, domain) - - logger.debug("blocked='%s' - DEOBFUSCATED!", blocked) - if blocked is None or blocked == "": - logger.warning("instance[host]='%s' is None or empty after tidyup.domain() - SKIPPED!", instance["host"]) - continue - elif not domain_helper.is_wanted(blocked): - logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked) - continue - - logger.debug("Appending blocker='%s',blocked='%s',block_level='%s' ...", domain, blocked, block_level) - blockdict.append({ - "blocker" : domain, - "blocked" : blocked, - "reason" : None, - "block_level": block_level, - }) + for blocked in blocklist: + logger.debug("blocked='%s' - BEFORE!", blocked) + blocked = tidyup.domain(blocked) if blocked != "" else None + logger.debug("blocked='%s' - AFTER!", blocked) + + if blocked is None or blocked == "": + logger.warning("blocked='%s' is empty after tidyup.domain(): domain='%s',block_level='%s' - SKIPPED!", blocked, domain, block_level) + continue + + logger.debug("Invoking utils.deobfuscate(%s, %s) ...", blocked, domain) + blocked = utils.deobfuscate(blocked, domain) + logger.debug("blocked='%s' - DEOBFUSCATED!", blocked) + + if blocked is None or blocked == "": + logger.warning("instance[host]='%s' is None or empty after tidyup.domain() - SKIPPED!", instance["host"]) + continue + elif not domain_helper.is_wanted(blocked): + logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked) + continue + + logger.debug("Appending blocker='%s',blocked='%s',block_level='%s' ...", domain, blocked, block_level) + blockdict.append({ + "blocker" : domain, + "blocked" : blocked, + "reason" : None, + "block_level": block_level, + }) elif "quarantined_instances" in data: logger.debug("Found 'quarantined_instances' in JSON response: domain='%s'", domain) found = True block_level = "quarantined" + logger.debug("Checking %d quarantined instance(s) ...", len(data["quarantined_instances"])) for blocked in data["quarantined_instances"]: logger.debug("blocked='%s' - BEFORE!", blocked) blocked = tidyup.domain(blocked) if blocked != "" else None @@ -255,7 +255,7 @@ def fetch_blocks(domain: str) -> list: logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s'", domain, block_level) continue - logger.debug("Checking %d blockdict records ...", len(blockdict)) + logger.debug("Checking %d blockdict record(s) ...", len(blockdict)) for block in blockdict: logger.debug("block[blocked]='%s',blocked='%s'", block["blocked"], blocked) if block["blocked"] == blocked: @@ -270,7 +270,7 @@ def fetch_blocks(domain: str) -> list: logger.debug("blocklist()=%d", len(blocklist)) if len(blocklist) > 0: - logger.info("Checking %d different blocklists ...", len(blocklist)) + logger.info("Checking %d different blocklist(s) ...", len(blocklist)) for block_level in blocklist: logger.debug("block_level='%s'", block_level) rows = blocklist[block_level]