# DEBUG: print("DEBUG: EXIT!")
return 0
-def fetch_federater(args: argparse.Namespace):
+def fetch_oliphant(args: argparse.Namespace):
# DEBUG: print(f"DEBUG: args[]='{type(args)}' - CALLED!")
locking.acquire()
- # Fetch this URL
- response = fba.fetch_url("https://github.com/federater/blocks_recommended/raw/main/federater.csv", network.web_headers, (config.get("connection_timeout"), config.get("read_timeout")))
- # DEBUG: print(f"DEBUG: response[]='{type(response)}'")
- if response.ok and response.content != "":
- # DEBUG: print(f"DEBUG: Fetched {len(response.content)} Bytes, parsing CSV ...")
- #print(f"DEBUG: response.content={response.content}")
- reader = csv.DictReader(response.content.decode('utf-8').splitlines(), dialect='unix')
- #, fieldnames='domain,severity,reject_media,reject_reports,public_comment,obfuscate'
- # DEBUG: print(f"DEBUG: reader[]='{type(reader)}'")
- for row in reader:
- if not validators.domain(row["#domain"]):
- print(f"WARNING: domain='{row['#domain']}' is not a valid domain - skipped!")
- continue
- elif blacklist.is_blacklisted(row["#domain"]):
- print(f"WARNING: domain='{row['#domain']}' is blacklisted - skipped!")
- continue
- elif instances.is_registered(row["#domain"]):
- # DEBUG: print(f"DEBUG: domain='{row['#domain']}' is already registered - skipped!")
- continue
+ # Base URL
+ base_url = "https://codeberg.org/oliphant/blocklists/raw/branch/main/blocklists"
+
+ # URLs to fetch
+ blocklists = (
+ {
+ "blocker": "artisan.chat",
+ "csv_url": "mastodon/artisan.chat.csv",
+ },{
+ "blocker": "mastodon.art",
+ "csv_url": "mastodon/mastodon.art.csv",
+ },{
+ "blocker": "pleroma.envs.net",
+ "csv_url": "mastodon/pleroma.envs.net.csv",
+ },{
+ "blocker": "oliphant.social",
+ "csv_url": "mastodon/_unified_tier3_blocklist.csv",
+ },{
+ "blocker": "mastodon.online",
+ "csv_url": "mastodon/mastodon.online.csv",
+ },{
+ "blocker": "mastodon.social",
+ "csv_url": "mastodon/mastodon.social.csv",
+ },{
+ "blocker": "mastodon.social",
+ "csv_url": "other/missing-tier0-mastodon.social.csv",
+ },{
+ "blocker": "rage.love",
+ "csv_url": "mastodon/rage.love.csv",
+ },{
+ "blocker": "sunny.garden",
+ "csv_url": "mastodon/sunny.garden.csv",
+ },{
+ "blocker": "solarpunk.moe",
+ "csv_url": "mastodon/solarpunk.moe.csv",
+ },{
+ "blocker": "toot.wales",
+ "csv_url": "mastodon/toot.wales.csv",
+ },{
+ "blocker": "union.place",
+ "csv_url": "mastodon/union.place.csv",
+ }
+ )
- try:
- print(f"INFO: Fetching instances for instane='{row['#domain']}' ...")
- federation.fetch_instances(row["#domain"], None, None, inspect.currentframe().f_code.co_name)
- except network.exceptions as exception:
- print(f"WARNING: Exception '{type(exception)}' during fetching instances from domain='{row['#domain']}'")
- instances.update_last_error(row["#domain"], exception)
+ for block in blocklists:
+ # Fetch this URL
+ print(f"DEBUG: Fetching csv_url='{block['csv_url']}' for blocker='{block['blocker']}' ...")
+ response = fba.fetch_url(f"{base_url}/{block['csv_url']}", network.web_headers, (config.get("connection_timeout"), config.get("read_timeout")))
+
+ # DEBUG: print(f"DEBUG: response[]='{type(response)}'")
+ if response.ok and response.content != "":
+ # DEBUG: print(f"DEBUG: Fetched {len(response.content)} Bytes, parsing CSV ...")
+ #print(f"DEBUG: response.content={response.content}")
+ reader = csv.DictReader(response.content.decode('utf-8').splitlines(), dialect="unix")
+ #, fieldnames='domain,severity,reject_media,reject_reports,public_comment,obfuscate'
+ # DEBUG: print(f"DEBUG: reader[]='{type(reader)}'")
+ for row in reader:
+ if not validators.domain(row["#domain"]):
+ print(f"WARNING: domain='{row['#domain']}' is not a valid domain - skipped!")
+ continue
+ elif blacklist.is_blacklisted(row["#domain"]):
+ print(f"WARNING: domain='{row['#domain']}' is blacklisted - skipped!")
+ continue
+
+ try:
+ print(f"INFO: Fetching instances for instane='{row['#domain']}' ...")
+ federation.fetch_instances(row["#domain"], block["blocker"], None, inspect.currentframe().f_code.co_name)
+ except network.exceptions as exception:
+ print(f"WARNING: Exception '{type(exception)}' during fetching instances from domain='{row['#domain']}'")
+ instances.update_last_error(row["#domain"], exception)
# DEBUG: print("DEBUG: EXIT!")