]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 6 Sep 2023 02:02:26 +0000 (04:02 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 6 Sep 2023 02:02:26 +0000 (04:02 +0200)
- introduced software_helper.is_relay() function to check if given software name
  is a supported relay software
- federation.fetch_instances() will throw an exception if invoked with relay
  software
- also command fetch_instances avoids them

fba/commands.py
fba/helpers/software.py
fba/http/federation.py

index 99a2870e5e2ad1c16674d330e27ed1202ee0bbbf..b7c967ecc21ab7de086980aae40b965d9b7efbf8 100644 (file)
@@ -318,7 +318,7 @@ def fetch_blocks(args: argparse.Namespace) -> int:
         instances.set_has_obfuscation(blocker, False)
 
         # c.s isn't part of oliphant's "hidden" blocklists
-        if blocker == "chaos.social" or blocklists.has(blocker):
+        if blocker == "chaos.social" or software_helper.is_relay(software) or blocklists.has(blocker):
             logger.debug("Skipping blocker='%s', run ./fba.py fetch_cs or fetch_oliphant instead!", blocker)
             continue
 
@@ -940,6 +940,10 @@ def fetch_instances(args: argparse.Namespace) -> int:
         origin = row["origin"]
         software = row["software"]
 
+    if software_helper.is_relay(software):
+        logger.warning("args.domain='%s' is of software type '%s' which is not supported by this command. Please invoke fetch_relays instead.", args.domain, software)
+        return 102
+
     # Initial fetch
     try:
         logger.info("Fetching instances from args.domain='%s',origin='%s',software='%s' ...", domain, origin, software)
@@ -1560,7 +1564,7 @@ def recheck_obfuscation(args: argparse.Namespace) -> int:
 
         # c.s isn't part of oliphant's "hidden" blocklists
         logger.debug("row[domain]='%s'", row["domain"])
-        if row["domain"] != "chaos.social" and not blocklists.has(row["domain"]):
+        if row["domain"] != "chaos.social" and not software_helper.is_relay(software) and not blocklists.has(row["domain"]):
             logger.debug("Invoking instances.set_total_blocks(%s, %d) ...", row["domain"], len(blocking))
             instances.set_last_blocked(row["domain"])
             instances.set_total_blocks(row["domain"], blocking)
index 6464e03cc1dc0f8bfefbe710d701c7340b861ee7..1399c225514ed7bdc877c96bfe754a7a21dfd79f 100644 (file)
@@ -21,6 +21,14 @@ from fba.helpers import tidyup
 logging.basicConfig(level=logging.INFO)
 logger = logging.getLogger(__name__)
 
+# A list of relay software
+relays = [
+    "activityrelay",
+    "aoderelay",
+    "selective-relay",
+    "pub-relay"
+]
+
 def alias(software: str) -> str:
     logger.debug("software='%s'- CALLED!", software)
 
@@ -184,3 +192,13 @@ def strip_until(software: str, until: str) -> str:
 
     logger.debug("software='%s' - EXIT!", software)
     return software
+
+def is_relay(software: str) -> bool:
+    logger.debug("software='%s'- CALLED!", software)
+
+    if not isinstance(software, str) and software is not None:
+        raise ValueError(f"software[]='{type(software)}' is not type 'str'")
+
+    found = software in relays
+    logger.debug("found='%s' - EXIT!", found)
+    return found
index e913af2ec9271bcfa08189d809f9bd65dbe62ca8..49f5c52020a1b154864d39d5b49637f994cb67d6 100644 (file)
@@ -178,6 +178,8 @@ def fetch_peers(domain: str, software: str, origin: str) -> list:
 
     if not isinstance(software, str) and software is not None:
         raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'")
+    elif software_helper.is_relay(software):
+        raise ValueError(f"domain='{domain}' is of software='{software}' and isn't supported here.")
     elif not isinstance(origin, str) and origin is not None:
         raise ValueError(f"Parameter origin[]='{type(origin)}' is not of type 'str'")
     elif isinstance(origin, str) and origin == "":