From: Roland Häder Date: Tue, 20 Jun 2023 02:43:30 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=23becba8cd2a494bb177e5fae4f86b520731f237;p=fba.git Continued: - 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) --- diff --git a/fba/blacklist.py b/fba/blacklist.py index 0877db4..bbe097b 100644 --- a/fba/blacklist.py +++ b/fba/blacklist.py @@ -30,6 +30,8 @@ blacklist = [ "ngrok.io", "ngrok-free.app", "misskeytest.chn.moe", + # block flooder + "everyoneattack.com", ] def is_blacklisted(domain: str) -> bool: diff --git a/fba/commands.py b/fba/commands.py index bc656dd..8777293 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -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!") diff --git a/fba/federation.py b/fba/federation.py index 754e0d6..71e02d9 100644 --- a/fba/federation.py +++ b/fba/federation.py @@ -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}'") diff --git a/fba/models/blocks.py b/fba/models/blocks.py index d8a8129..1ede1c7 100644 --- a/fba/models/blocks.py +++ b/fba/models/blocks.py @@ -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!")