]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 11 Jun 2023 02:53:42 +0000 (04:53 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 11 Jun 2023 02:53:42 +0000 (04:53 +0200)
- also need to put a try/except block around csrf.determine() invocations

fba/commands.py
fba/federation.py
fba/networks/lemmy.py
fba/networks/mastodon.py
fba/networks/misskey.py
fba/networks/peertube.py
fba/networks/pleroma.py

index 401f6a4701bc089f3b8f47c02ded8125e10a6d83..078bc4ff441d0a096f7e82ee0d492865e758ceff 100644 (file)
@@ -206,7 +206,7 @@ def fetch_blocks(args: argparse.Namespace):
 
                         searchres = fba.cursor.fetchone()
 
-                        print(f"DEBUG: searchres[]='{type(searchres)}'")
+                        # DEBUG: print(f"DEBUG: searchres[]='{type(searchres)}'")
                         if searchres is None:
                             print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!")
                             continue
@@ -222,7 +222,7 @@ def fetch_blocks(args: argparse.Namespace):
 
                         searchres = fba.cursor.fetchone()
 
-                        print(f"DEBUG: searchres[]='{type(searchres)}'")
+                        # DEBUG: print(f"DEBUG: searchres[]='{type(searchres)}'")
                         if searchres is None:
                             print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!")
                             continue
index df408cb8b0beca0d9327841c608973cb4aced081..9f1e0098cc4f09f21a844259488bfcd0e04a800a 100644 (file)
@@ -122,9 +122,14 @@ def fetch_peers(domain: str, software: str) -> list:
 
     # Init peers variable
     peers = list()
+    headers = tuple()
 
     # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
-    headers = csrf.determine(domain, dict())
+    try:
+       headers = csrf.determine(domain, dict())
+    except network.exceptions as exception:
+        print(f"WARNING: Exception '{type(exception)}' during checking CSRF - EXIT!")
+        return
 
     # DEBUG: print(f"DEBUG: Fetching peers from '{domain}',software='{software}' ...")
     data = network.get_json_api(
@@ -185,8 +190,14 @@ def fetch_nodeinfo(domain: str, path: str = None) -> list:
         # DEBUG: print("DEBUG: nodeinfo()={len(nodeinfo))} - EXIT!")
         return nodeinfo
 
+    headers = tuple()
+
     # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
-    headers = csrf.determine(domain, dict())
+    try:
+       headers = csrf.determine(domain, dict())
+    except network.exceptions as exception:
+        print(f"WARNING: Exception '{type(exception)}' during checking CSRF - EXIT!")
+        return
 
     request_paths = [
        "/nodeinfo/2.1.json",
@@ -229,8 +240,14 @@ def fetch_wellknown_nodeinfo(domain: str) -> list:
     elif domain == "":
         raise ValueError("Parameter 'domain' is empty")
 
+    headers = tuple()
+
     # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
-    headers = csrf.determine(domain, dict())
+    try:
+       headers = csrf.determine(domain, dict())
+    except network.exceptions as exception:
+        print(f"WARNING: Exception '{type(exception)}' during checking CSRF - EXIT!")
+        return
 
     # DEBUG: print("DEBUG: Fetching .well-known info for domain:", domain)
     data = network.get_json_api(
index df63ae0e6d0765bac4f1ac601fb127df2f03a313..9b283c0dc7373a30b33eea600d9f0e40e58e2027 100644 (file)
@@ -27,8 +27,14 @@ def fetch_peers(domain: str) -> list:
     elif domain == "":
         raise ValueError("Parameter 'domain' is empty")
 
-    print(f"DEBUG: Checking CSRF for domain='{domain}'")
-    headers = csrf.determine(domain, dict())
+    headers = tuple()
+
+    # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
+    try:
+       headers = csrf.determine(domain, dict())
+    except network.exceptions as exception:
+        print(f"WARNING: Exception '{type(exception)}' during checking CSRF - EXIT!")
+        return
 
     peers = list()
     try:
index 424a0236e7c9275975192fc148241e3c59aaf749..2ce63310f30ed7983e90576aae2b8e497a6b0e96 100644 (file)
@@ -131,8 +131,14 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
     elif nodeinfo_url == "":
         raise ValueError("Parameter 'nodeinfo_url' is empty")
 
-    print(f"DEBUG: Checking CSRF for domain='{domain}'")
-    headers = csrf.determine(domain, dict())
+    headers = tuple()
+
+    # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
+    try:
+       headers = csrf.determine(domain, dict())
+    except network.exceptions as exception:
+        print(f"WARNING: Exception '{type(exception)}' during checking CSRF - EXIT!")
+        return
 
     try:
         # json endpoint for newer mastodongs
@@ -222,7 +228,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                     )
                     searchres = fba.cursor.fetchone()
 
-                    print(f"DEBUG: searchres[]='{type(searchres)}'")
+                    # DEBUG: print(f"DEBUG: searchres[]='{type(searchres)}'")
                     if searchres is None:
                         print(f"WARNING: Cannot deobsfucate blocked='{blocked}',blocked_hash='{blocked_hash}' - SKIPPED!")
                         continue
index f3a1eb30dcd7a53cd6a42f2c4255b20325dfc5bb..f7979120e79f04c6b79396ec69b3b31a89533c3b 100644 (file)
@@ -38,7 +38,14 @@ def fetch_peers(domain: str) -> list:
     peers   = list()
     offset  = 0
     step    = config.get("misskey_limit")
-    headers = csrf.determine(domain, {"Origin": domain})
+    headers = tuple()
+
+    # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
+    try:
+       headers = csrf.determine(domain, dict())
+    except network.exceptions as exception:
+        print(f"WARNING: Exception '{type(exception)}' during checking CSRF - EXIT!")
+        return
 
     # iterating through all "suspended" (follow-only in its terminology)
     # instances page-by-page, since that troonware doesn't support
@@ -132,7 +139,14 @@ def fetch_blocks(domain: str) -> dict:
 
     offset  = 0
     step    = config.get("misskey_limit")
-    headers = csrf.determine(domain, {"Origin": domain})
+    headers = tuple()
+
+    # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
+    try:
+       headers = csrf.determine(domain, dict())
+    except network.exceptions as exception:
+        print(f"WARNING: Exception '{type(exception)}' during checking CSRF - EXIT!")
+        return
 
     # iterating through all "suspended" (follow-only in its terminology)
     # instances page-by-page since it doesn't support sending them all at once
index 96fc880b0234ad303ae8e5a2636e439747c7b2fa..44c8c074157f2e613b1435113ba9d9be1a748a65 100644 (file)
@@ -27,11 +27,16 @@ def fetch_peers(domain: str) -> list:
         raise ValueError("Parameter 'domain' is empty")
 
     print(f"DEBUG: domain='{domain}' is a PeerTube, fetching JSON ...")
-    peers = list()
-    start = 0
+    peers   = list()
+    start   = 0
+    headers = tuple()
 
     print(f"DEBUG: Checking CSRF for domain='{domain}'")
-    headers = csrf.determine(domain, dict())
+    try:
+       headers = csrf.determine(domain, dict())
+    except network.exceptions as exception:
+        print(f"WARNING: Exception '{type(exception)}' during checking CSRF - EXIT!")
+        return
 
     for mode in ["followers", "following"]:
         print(f"DEBUG: domain='{domain}',mode='{mode}'")
index 86f69cdee9cd47809de2801908d7f9cfd55856d1..8941b8a7f81bee5d7ea64a4c4205bc119fcd1c52 100644 (file)
@@ -173,7 +173,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                         )
                         searchres = fba.cursor.fetchone()
 
-                        print(f"DEBUG: searchres[]='{type(searchres)}'")
+                        # DEBUG: print(f"DEBUG: searchres[]='{type(searchres)}'")
                         if searchres is None:
                             print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!")
                             continue