)
for blocker, software in fba.c.fetchall():
- print("DEBUG: blocker,software:", blocker, software)
+ # NOISY-DEBUG: print("DEBUG: blocker,software:", blocker, software)
blockdict = []
blocker = fba.tidyup(blocker)
if software == "pleroma":
**{"quarantined_instances": federation["quarantined_instances"]}}
).items():
for blocked in blocks:
- print("DEBUG: BEFORE blocked:", blocked)
+ # NOISY-DEBUG: print("DEBUG: BEFORE blocked:", blocked)
blocked = fba.tidyup(blocked)
- print("DEBUG: AFTER blocked:", blocked)
+ # NOISY-DEBUG: print("DEBUG: AFTER blocked:", blocked)
if blocked == "":
print("WARNING: blocked is empty after fba.tidyup():", blocker, block_level)
"SELECT domain FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", (blocked.replace("*", "_"),)
)
searchres = fba.c.fetchone()
- print("DEBUG: searchres[]:", type(searchres))
+ # NOISY-DEBUG: print("DEBUG: searchres[]:", type(searchres))
if searchres != None:
blocked = searchres[0]
- print("DEBUG: Looking up instance by domain:", blocked)
+ # NOISY-DEBUG: print("DEBUG: Looking up instance by domain:", blocked)
fba.c.execute(
"SELECT domain FROM instances WHERE domain = ?", (blocked,)
)
if fba.c.fetchone() == None:
- print("DEBUG: Domain wasn't found, adding:", blocked)
+ # NOISY-DEBUG: print("DEBUG: Domain wasn't found, adding:", blocked)
fba.add_instance(blocked)
timestamp = int(time.time())
# Reasons
if "mrf_simple_info" in federation:
- print("DEBUG: Found mrf_simple_info:", blocker)
+ # NOISY-DEBUG: print("DEBUG: Found mrf_simple_info:", blocker)
for block_level, info in (
{**federation["mrf_simple_info"],
**(federation["quarantined_instances_info"]
if "quarantined_instances_info" in federation
else {})}
).items():
- print("DEBUG: block_level, info.items():", block_level, len(info.items()))
+ # NOISY-DEBUG: print("DEBUG: block_level, info.items():", block_level, len(info.items()))
for blocked, reason in info.items():
- print("DEBUG: BEFORE blocked:", blocked)
+ # NOISY-DEBUG: print("DEBUG: BEFORE blocked:", blocked)
blocked = fba.tidyup(blocked)
- print("DEBUG: AFTER blocked:", blocked)
+ # NOISY-DEBUG: print("DEBUG: AFTER blocked:", blocked)
if blocked == "":
print("WARNING: blocked is empty after fba.tidyup():", blocker, block_level)
if searchres != None:
blocked = searchres[0]
- print("DEBUG: Updating block reason:", blocker, blocked, reason["reason"])
+ # NOISY-DEBUG: print("DEBUG: Updating block reason:", blocker, blocked, reason["reason"])
fba.update_block_reason(reason["reason"], blocker, blocked, block_level)
for entry in blockdict:
if entry["blocked"] == blocked:
- print("DEBUG: Updating entry reason:", blocked)
+ # NOISY-DEBUG: print("DEBUG: Updating entry reason:", blocked)
entry["reason"] = reason["reason"]
fba.conn.commit()
}
# handling CSRF, I've saw at least one server requiring it to access the endpoint
- print("DEBUG: Fetching meta:", blocker)
+ # NOISY-DEBUG: 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"]
- print("DEBUG: Adding CSRF token:", blocker, csrf)
+ # NOISY-DEBUG: print("DEBUG: Adding CSRF token:", blocker, csrf)
reqheaders = {**fba.headers, **{"x-csrf-token": csrf}}
except:
- print("DEBUG: No CSRF token found, using normal headers:", blocker)
+ # NOISY-DEBUG: print("DEBUG: No CSRF token found, using normal headers:", blocker)
reqheaders = fba.headers
- print("DEBUG: Quering API domain_blocks:", blocker)
+ # NOISY-DEBUG: print("DEBUG: Quering API domain_blocks:", blocker)
blocks = reqto.get(
f"https://{blocker}/api/v1/instance/domain_blocks", headers=reqheaders, timeout=5
).json()
- print("DEBUG: blocks():", len(blocks))
+ # NOISY-DEBUG: print("DEBUG: blocks():", len(blocks))
for block in blocks:
entry = {'domain': block['domain'], 'hash': block['digest'], 'reason': block['comment']}
- print("DEBUG: severity,domain,hash,comment:", block['severity'], block['domain'], block['digest'], block['comment'])
+ # NOISY-DEBUG: print("DEBUG: severity,domain,hash,comment:", block['severity'], block['domain'], block['digest'], block['comment'])
if block['severity'] == 'suspend':
json['reject'].append(entry)
elif block['severity'] == 'silence':
else:
print("WARNING: Unknown severity:", block['severity'], block['domain'])
except:
- print("DEBUG: Failed, Trying mastodon-specific fetches:", blocker)
+ # NOISY-DEBUG: print("DEBUG: Failed, Trying mastodon-specific fetches:", blocker)
json = fba.get_mastodon_blocks(blocker)
- print("DEBUG: json.items():", blocker, len(json.items()))
+ # NOISY-DEBUG: 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))
+ # NOISY-DEBUG: 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)
+ # NOISY-DEBUG: print("DEBUG: blocked,hash,reason:", blocked, blocked_hash, reason)
blocked = fba.tidyup(blocked)
- print("DEBUG: blocked:", blocked)
+ # NOISY-DEBUG: print("DEBUG: blocked:", blocked)
if blocked.count("*") < 1:
# No obsfucation for this instance
)
if fba.c.fetchone() == None:
- print("DEBUG: Hash wasn't found, adding:", blocked)
+ # NOISY-DEBUG: print("DEBUG: Hash wasn't found, adding:", blocked)
fba.add_instance(blocked)
else:
# Doing the hash search for instance names as well to tidy up DB
searchres = fba.c.fetchone()
if searchres != None:
- print("DEBUG: Updating domain: ", searchres[0])
+ # NOISY-DEBUG: print("DEBUG: Updating domain: ", searchres[0])
blocked = searchres[0]
timestamp = int(time.time())
fba.update_last_seen(timestamp, blocker, blocked if blocked.count("*") <= 1 else blocked_hash, block_level)
if reason != '':
- print("DEBUG: Updating block reason:", blocker, blocked, reason)
+ # NOISY-DEBUG: print("DEBUG: Updating block reason:", blocker, blocked, reason)
fba.update_block_reason(reason, blocker, blocked if blocked.count("*") <= 1 else blocked_hash, block_level)
fba.conn.commit()
blocked, reason = instance.values()
blocked = fba.tidyup(blocked)
- print("BEFORE-blocked:", blocked)
+ # NOISY-DEBUG: print("DEBUG: BEFORE-blocked:", blocked)
if blocked.count("*") > 0:
# Some friendica servers also obscure domains without hash
fba.c.execute(
if searchres != None:
blocked = searchres[0]
- print("AFTER-blocked:", blocked)
+ # NOISY-DEBUG: print("DEBUG: AFTER-blocked:", blocked)
fba.c.execute(
"SELECT domain FROM instances WHERE domain = ?", (blocked,)
)
if fba.c.fetchone() == None:
- print("DEBUG: Hash wasn't found, adding:", blocked)
+ # NOISY-DEBUG: print("DEBUG: Hash wasn't found, adding:", blocked)
fba.add_instance(blocked)
timestamp = int(time.time())
fba.update_last_seen(timestamp, blocker, blocked, block_level)
if reason != '':
- print("DEBUG: Updating block reason:", blocker, blocked, reason)
+ # NOISY-DEBUG: print("DEBUG: Updating block reason:", blocker, blocked, reason)
fba.update_block_reason(reason, blocker, blocked, block_level)
fba.conn.commit()
print("WARNING: No valid response:", blocker);
else:
for peer in federation:
- print("DEBUG: peer(),[]:", len(peer), type(peer))
+ # NOISY-DEBUG: print("DEBUG: peer(),[]:", len(peer), type(peer))
if (isinstance(peer, str) and peer == "error"):
print("WARNING: Cannot continue, maybe authentication required?", blocker)
break
blocked = peer["domain"].lower()
- print("DEBUG: blocked:", blocked)
+ # NOISY-DEBUG: print("DEBUG: blocked:", blocked)
if blocked.count("*") > 0:
# GTS does not have hashes for obscured domains, so we have to guess it
)
if fba.c.fetchone() == None:
- print("DEBUG: Hash wasn't found, adding:", blocked)
+ # NOISY-DEBUG: print("DEBUG: Hash wasn't found, adding:", blocked)
fba.add_instance(blocked)
fba.c.execute(
if "public_comment" in peer:
reason = peer["public_comment"]
- print("DEBUG: Updating block reason:", blocker, blocked, reason)
+ # NOISY-DEBUG: print("DEBUG: Updating block reason:", blocker, blocked, reason)
fba.update_block_reason(reason, blocker, blocked, "reject")
for entry in blockdict: