]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 20 Jun 2023 18:34:58 +0000 (20:34 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 20 Jun 2023 18:34:58 +0000 (20:34 +0200)
- imported needed module fba.helpers.cookies
- some nodeinfo may return blacklisted or invalid domains, let's skip them here

fba/commands.py
fba/federation.py

index 190a92d675e453994de8de5bc4fbc5283e02fbc6..ddeb8ec474527abe2dbb9446988403a23638bac5 100644 (file)
@@ -32,6 +32,7 @@ from fba import federation
 from fba import fba
 from fba import network
 
+from fba.helpers import cookies
 from fba.helpers import locking
 from fba.helpers import tidyup
 
@@ -177,7 +178,7 @@ def fetch_blocks(args: argparse.Namespace):
             print("WARNING: blocker is now empty!")
             continue
         elif nodeinfo_url is None or nodeinfo_url == "":
-            print(f"DEBUG: blocker='{blocker}',software='{software}' has empty nodeinfo_url")
+            # DEBUG: print(f"DEBUG: blocker='{blocker}',software='{software}' has empty nodeinfo_url")
             continue
         elif blacklist.is_blacklisted(blocker):
             print(f"WARNING: blocker='{blocker}' is blacklisted now!")
index e583949410a5742463c635924d52f7de2ba768bd..c9d959226e5cfe6bc7b4e6322ebe87a7b2114cba 100644 (file)
@@ -77,9 +77,6 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
         raise ValueError(f"Parameter command[]='{type(command)}' is not 'str'")
     elif command == "":
         raise ValueError("Parameter 'command' is empty")
-    elif domain.endswith(".arpa"):
-        print(f"WARNING: domain='{domain}' is a reversed .arpa domain and should not be used generally.")
-        return
     elif not validators.domain(domain.split("/")[0]):
         raise ValueError(f"domain='{domain}' is not a valid domain")
     elif domain.endswith(".arpa"):
@@ -127,11 +124,6 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
         elif blacklist.is_blacklisted(instance):
             # DEBUG: print("DEBUG: instance is blacklisted:", instance)
             continue
-
-        # DEBUG: print("DEBUG: Handling instance:", instance)
-        if instance.endswith(".arpa"):
-            print(f"WARNING: instance='{instance}' is a reversed .arpa domain and should not be used generally.")
-            continue
         elif instance.find("/profile/") > 0 or instance.find("/users/") > 0:
             # DEBUG: print(f"DEBUG: instance='{instance}' is a link to a single user profile - SKIPPED!")
             continue
@@ -354,6 +346,14 @@ def fetch_wellknown_nodeinfo(domain: str) -> dict:
                     if components.scheme == "" and components.netloc == "":
                         # DEBUG: print(f"DEBUG: link[href]='{link['href']}' has no scheme and host name in it, prepending from domain='{domain}'")
                         url = f"https://{domain}{url}"
+                        components = urlparse(url)
+
+                    if blacklist.is_blacklisted(components.netloc):
+                        print(f"WARNING: components.netloc='{components.netloc}' is blacklisted - SKIPPED!")
+                        continue
+                    elif not validators.domain(components.netloc):
+                        print(f"WARNING: components.netloc='{components.netloc}' is not a valid domain - SKIPPED!")
+                        continue
 
                     # DEBUG: print("DEBUG: Fetching nodeinfo from:", url)
                     data = network.fetch_api_url(