From eba1de29be9481b325e8be0d249e774bf4a4e2b7 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Sat, 13 Jul 2024 11:21:44 +0200
Subject: [PATCH] Continued: - invalid domains should most be logged as
 warnings, not debug levels but   sometimes it is okay - allow RFC 2782
 compliant domains (with underscore)

---
 fba/commands.py           | 2 +-
 fba/helpers/processing.py | 2 +-
 fba/http/federation.py    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fba/commands.py b/fba/commands.py
index 5848fbc..1e0ccb3 100644
--- a/fba/commands.py
+++ b/fba/commands.py
@@ -424,7 +424,7 @@ 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"]):
+            elif not validators.domain(block["blocked"], rfc_2782=True):
                 logger.warning("block[blocked]='%s' is not a valid domain - SKIPPED!", block["blocked"])
                 continue
             elif block["blocked"].endswith(".onion"):
diff --git a/fba/helpers/processing.py b/fba/helpers/processing.py
index 01c66d4..856acf3 100644
--- a/fba/helpers/processing.py
+++ b/fba/helpers/processing.py
@@ -227,7 +227,7 @@ def csv_block(blocker: str, url: str, command: str):
         domains.append(domain)
 
         if not validators.domain(domain, rfc_2782=True):
-            logger.debug("domain='%s' is not a valid domain - SKIPPED!")
+            logger.warning("domain='%s' is not a valid domain - SKIPPED!")
             continue
         elif blacklist.is_blacklisted(domain):
             logger.debug("domain='%s' is blacklisted - SKIPPED!", domain)
diff --git a/fba/http/federation.py b/fba/http/federation.py
index 53232d2..994a32b 100644
--- a/fba/http/federation.py
+++ b/fba/http/federation.py
@@ -173,7 +173,7 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
 
         logger.debug("instance='%s'", instance)
         if not validators.domain(instance, rfc_2782=True):
-            logger.debug("instance='%s' is not a valid domain - SKIPPED!", instance)
+            logger.warning("instance='%s' is not a valid domain - SKIPPED!", instance)
             continue
         elif instance.endswith(".onion"):
             logger.debug("instance='%s' is a TOR .onion instance - SKIPPED", instance)
-- 
2.39.5