From: Roland Häder Date: Sat, 13 Jul 2024 09:19:07 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=159e110a921c7c00aa6961afc37493a43de617c1;p=fba.git Continued: - skip invalid domains (warning) - skip .arpa/i2p/onion/tld (I2P might be allowed) --- diff --git a/fba/commands.py b/fba/commands.py index 30673d1..5848fbc 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -424,6 +424,21 @@ def fetch_blocks(args: argparse.Namespace) -> int: if block["blocked"] in [None, ""]: logger.debug("block[blocked]='%s' is empty - SKIPPED!", block["blocked"]) continue + elif not validators.domain(block["blocked"]): + logger.warning("block[blocked]='%s' is not a valid domain - SKIPPED!", block["blocked"]) + continue + elif block["blocked"].endswith(".onion"): + logger.debug("block[blocked]'%s' is a TOR .onion domain - SKIPPED", block["blocked"]) + continue + elif block["blocked"].endswith(".i2p") and not config.get("allow_i2p_domain"): + logger.debug("block[blocked]'%s' is an I2P .onion domain - SKIPPED", block["blocked"]) + continue + elif block["blocked"].endswith(".arpa"): + logger.debug("block[blocked]'%s' is a reverse IP address - SKIPPED", block["blocked"]) + continue + elif block["blocked"].endswith(".tld"): + logger.debug("block[blocked]'%s' is a fake domain - SKIPPED", block["blocked"]) + continue logger.debug("block[blocked]='%s' - BEFORE!", block["blocked"]) block["blocked"] = domain_helper.encode_idna(block["blocked"]) @@ -436,13 +451,13 @@ def fetch_blocks(args: argparse.Namespace) -> int: logger.debug("block[blocked]='%s' is accepted, not wanted here - SKIPPED!", block["blocked"]) continue elif not instances.is_registered(block["blocked"]): - logger.debug("Hash wasn't found, adding: blocked='%s',blocker='%s'", block["blocked"], blocker) + logger.debug("Hash wasn't found, adding: block[blocked]'%s',blocker='%s'", block["blocked"], blocker) federation.fetch_instances(block["blocked"], blocker, None, inspect.currentframe().f_code.co_name) block["block_level"] = blocks.alias_block_level(block["block_level"]) if processing.block(blocker, block["blocked"], block["reason"], block["block_level"]) and block["block_level"] in ["reject", "suspend"] and config.get("bot_enabled"): - logger.debug("Appending blocked='%s',reason='%s' for blocker='%s' ...", block["blocked"], block["block_level"], blocker) + logger.debug("Appending block[blocked]'%s',reason='%s' for blocker='%s' ...", block["blocked"], block["block_level"], blocker) blockdict.append({ "blocked": block["blocked"], "reason" : block["reason"],