}
# handling CSRF, I've saw at least one server requiring it to access the endpoint
+ print("DEBUG: Fetching meta:", blocker)
meta = bs4.BeautifulSoup(
reqto.get(f"https://{blocker}/about", headers=fba.headers, timeout=5).text,
"html.parser",
)
try:
csrf = meta.find("meta", attrs={"name": "csrf-token"})["content"]
- reqfba.headers = {**fba.headers, **{"x-csrf-token": csrf}}
+ print("DEBUG: Adding CSRF token:", blocker, csrf)
+ reqheaders = {**fba.headers, **{"x-csrf-token": csrf}}
except:
- reqfba.headers = fba.headers
+ print("DEBUG: No CSRF token found, using normal headers:", blocker)
+ reqheaders = fba.headers
+ print("DEBUG: Quering API domain_blocks:", blocker)
blocks = reqto.get(
- f"https://{blocker}/api/v1/instance/domain_blocks", headers=reqfba.headers, timeout=5
+ f"https://{blocker}/api/v1/instance/domain_blocks", headers=reqheaders, timeout=5
).json()
print("DEBUG: blocks():", len(blocks))
else:
print("WARNING: Unknown severity:", block['severity'], block['domain'])
except:
+ print("DEBUG: Failed, Trying mastodon-specific fetches:", blocker)
json = fba.get_mastodon_blocks(blocker)
+ print("DEBUG: json.items():", blocker, len(json.items()))
for block_level, blocks in json.items():
+ print("DEBUG: blocker,block_level,blocks():", blocker, block_level, len(blocks))
for instance in blocks:
blocked, blocked_hash, reason = instance.values()
print("DEBUG: blocked,hash,reason:", blocked, blocked_hash, reason)