]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 20 Jun 2023 02:43:30 +0000 (04:43 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 20 Jun 2023 02:43:30 +0000 (04:43 +0200)
- new flooder everyoneattack.com added
- also ignored empty nodeinfo_url column
- WIP: commented out missing lemmy.fetch_blocks()
- also fixed some missing variables (removed from string)

fba/blacklist.py
fba/commands.py
fba/federation.py
fba/models/blocks.py

index 0877db45d747dd81a88ec9f18d1f4edc76bd4b8e..bbe097b1f8a6d5fd0f45e33cdb086c5dc8bf7a49 100644 (file)
@@ -30,6 +30,8 @@ blacklist = [
     "ngrok.io",
     "ngrok-free.app",
     "misskeytest.chn.moe",
+    # block flooder
+    "everyoneattack.com",
 ]
 
 def is_blacklisted(domain: str) -> bool:
index bc656dda09b8f44eae5e6babc1f22e6ef65d4654..87772930102d5e549eead70f4814c91a85b2f8d3 100644 (file)
@@ -167,6 +167,9 @@ def fetch_blocks(args: argparse.Namespace):
         if blocker == "":
             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")
+            continue
         elif blacklist.is_blacklisted(blocker):
             print(f"WARNING: blocker='{blocker}' is blacklisted now!")
             continue
@@ -182,7 +185,7 @@ def fetch_blocks(args: argparse.Namespace):
             mastodon.fetch_blocks(blocker, origin, nodeinfo_url)
         elif software == "lemmy":
             print(f"INFO: blocker='{blocker}',software='{software}'")
-            lemmy.fetch_blocks(blocker, origin, nodeinfo_url)
+            #lemmy.fetch_blocks(blocker, origin, nodeinfo_url)
         elif software == "friendica" or software == "misskey":
             print(f"INFO: blocker='{blocker}',software='{software}'")
 
@@ -319,12 +322,18 @@ def fetch_observer(args: argparse.Namespace):
 
     print(f"INFO: Fetching {len(types)} different table data ...")
     for software in types:
-        # DEBUG: print(f"DEBUG: Fetching table data for software='{software}' ...")
-        raw = fba.fetch_url(f"https://fediverse.observer/app/views/tabledata.php?software={software}", network.web_headers, (config.get("connection_timeout"), config.get("read_timeout"))).text
-        # DEBUG: print(f"DEBUG: raw[{type(raw)}]()={len(raw)}")
+        doc = None
+
+        try:
+            # DEBUG: print(f"DEBUG: Fetching table data for software='{software}' ...")
+            raw = fba.fetch_url(f"https://fediverse.observer/app/views/tabledata.php?software={software}", network.web_headers, (config.get("connection_timeout"), config.get("read_timeout"))).text
+            # DEBUG: print(f"DEBUG: raw[{type(raw)}]()={len(raw)}")
 
-        doc = bs4.BeautifulSoup(raw, features='html.parser')
-        # DEBUG: print(f"DEBUG: doc[]='{type(doc)}'")
+            doc = bs4.BeautifulSoup(raw, features='html.parser')
+            # DEBUG: print(f"DEBUG: doc[]='{type(doc)}'")
+        except network.exceptions as exception:
+            print(f"WARNING: Cannot fetch software='{software}' from fediverse.observer: '{type(exception)}'")
+            continue
 
         items = doc.findAll("a", {"class": "url"})
         print(f"INFO: Checking {len(items)} items,software='{software}' ...")
@@ -344,7 +353,7 @@ def fetch_observer(args: argparse.Namespace):
                 continue
 
             print(f"INFO: Fetching instances for domain='{domain}',software='{software}'")
-            federation.fetch_instances(domain, None, software, inspect.currentframe().f_code.co_name)
+            federation.fetch_instances(domain, None, None, inspect.currentframe().f_code.co_name)
 
     # DEBUG: print("DEBUG: EXIT!")
 
index 754e0d6b8c1fae0eca994cf0e92fbb2176afd174..71e02d91bbb9426eaf601c8adc914cc5753594ef 100644 (file)
@@ -78,6 +78,8 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
         return
     elif not validators.domain(domain.split("/")[0]):
         raise ValueError(f"domain='{domain}' is not a valid domain")
+    elif domain.endswith(".tld"):
+        raise ValueError(f"domain='{domain}' is a fake domain")
 
     if not instances.is_registered(domain):
         # DEBUG: print(f"DEBUG: Adding new domain='{domain}',origin='{origin}',command='{command}',path='{path}',software='{software}'")
index d8a8129e101a5924f21e228cc8a6c9509f84a01d..1ede1c726ba6bb7784916a988f6ad7978143a12b 100644 (file)
@@ -54,7 +54,7 @@ def update_reason(reason: str, blocker: str, blocked: str, block_level: str):
 
     # DEBUG: print(f"DEBUG: fba.cursor.rowcount={fba.cursor.rowcount}")
     if fba.cursor.rowcount == 0:
-        raise Exception(f"Did not update any rows: domain='{domain}',fields()={len(fields)}")
+        raise Exception(f"Did not update any rows: blocker='{blocker}'")
 
     # DEBUG: print("DEBUG: EXIT!")
 
@@ -86,7 +86,7 @@ def update_last_seen(blocker: str, blocked: str, block_level: str):
 
     # DEBUG: print(f"DEBUG: fba.cursor.rowcount={fba.cursor.rowcount}")
     if fba.cursor.rowcount == 0:
-        raise Exception(f"Did not update any rows: domain='{domain}',fields()={len(fields)}")
+        raise Exception(f"Did not update any rows: blocker='{blocker}'")
 
     # DEBUG: print("DEBUG: EXIT!")