]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 13 Jul 2024 09:19:07 +0000 (11:19 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 13 Jul 2024 09:19:07 +0000 (11:19 +0200)
- skip invalid domains (warning)
- skip .arpa/i2p/onion/tld (I2P might be allowed)

fba/commands.py

index 30673d142badac412b8ce5ff2a21ca969000a218..5848fbc20550ac3ee9c04b1dc0c694f43fc58d72 100644 (file)
@@ -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"],