logger.info("Checking %d entries ...", len(rows))
for blocker, software, origin, nodeinfo_url in rows:
logger.debug("blocker='%s',software='%s',origin='%s',nodeinfo_url='%s'", blocker, software, origin, nodeinfo_url)
- blocker = tidyup.domain(blocker)
- logger.debug("blocker='%s' - AFTER!", blocker)
- if blocker == "":
- logger.warning("blocker is now empty!")
- continue
- elif nodeinfo_url is None or nodeinfo_url == "":
- logger.debug("blocker='%s',software='%s' has empty nodeinfo_url", blocker, software)
+ if nodeinfo_url is None:
+ logger.debug("blocker='%s',software='%s' has no nodeinfo_url set - SKIPPED!", blocker, software)
continue
elif not domain_helper.is_wanted(blocker):
- logger.debug("blocker='%s' is not wanted - SKIPPED!", blocker)
+ logger.warning("blocker='%s' is not wanted - SKIPPED!", blocker)
continue
- logger.debug("blocker='%s'", blocker)
+ logger.debug("Setting last_blocked,has_obfuscation=false for blocker='%s' ...", blocker)
instances.set_last_blocked(blocker)
instances.set_has_obfuscation(blocker, False)
blocking = list()
- if software == "pleroma":
- logger.info("blocker='%s',software='%s'", blocker, software)
- blocking = pleroma.fetch_blocks(blocker, nodeinfo_url)
- logger.debug("blocker='%s' returned %d entries,software='%s'", blocker, len(blocking), software)
- elif software == "mastodon":
- logger.info("blocker='%s',software='%s'", blocker, software)
- blocking = mastodon.fetch_blocks(blocker, nodeinfo_url)
- logger.debug("blocker='%s' returned %d entries,software='%s'", blocker, len(blocking), software)
- elif software == "lemmy":
- logger.info("blocker='%s',software='%s'", blocker, software)
- blocking = lemmy.fetch_blocks(blocker, nodeinfo_url)
- logger.debug("blocker='%s' returned %d entries,software='%s'", blocker, len(blocking), software)
- elif software == "friendica":
- logger.info("blocker='%s',software='%s'", blocker, software)
- blocking = friendica.fetch_blocks(blocker)
- logger.debug("blocker='%s' returned %d entries,software='%s'", blocker, len(blocking), software)
- elif software == "misskey":
- logger.info("blocker='%s',software='%s'", blocker, software)
- blocking = misskey.fetch_blocks(blocker)
- logger.debug("blocker='%s' returned %d entries,software='%s'", blocker, len(blocking), software)
- else:
- logger.warning("Unknown software: blocker='%s',software='%s'", blocker, software)
- logger.debug("blocker='%s'", blocker)
if blocker != "chaos.social":
+ logger.debug("blocker='%s',software='%s'", blocker, software)
+ if software == "pleroma":
+ logger.info("blocker='%s',software='%s'", blocker, software)
+ blocking = pleroma.fetch_blocks(blocker, nodeinfo_url)
+ logger.debug("blocker='%s' returned %d entries,software='%s'", blocker, len(blocking), software)
+ elif software == "mastodon":
+ logger.info("blocker='%s',software='%s'", blocker, software)
+ blocking = mastodon.fetch_blocks(blocker, nodeinfo_url)
+ logger.debug("blocker='%s' returned %d entries,software='%s'", blocker, len(blocking), software)
+ elif software == "lemmy":
+ logger.info("blocker='%s',software='%s'", blocker, software)
+ blocking = lemmy.fetch_blocks(blocker, nodeinfo_url)
+ logger.debug("blocker='%s' returned %d entries,software='%s'", blocker, len(blocking), software)
+ elif software == "friendica":
+ logger.info("blocker='%s',software='%s'", blocker, software)
+ blocking = friendica.fetch_blocks(blocker)
+ logger.debug("blocker='%s' returned %d entries,software='%s'", blocker, len(blocking), software)
+ elif software == "misskey":
+ logger.info("blocker='%s',software='%s'", blocker, software)
+ blocking = misskey.fetch_blocks(blocker)
+ logger.debug("blocker='%s' returned %d entries,software='%s'", blocker, len(blocking), software)
+ else:
+ logger.warning("Unknown software: blocker='%s',software='%s'", blocker, software)
+
logger.debug("Invoking instances.set_total_blocks(%s, %d) ...", blocker, len(blocking))
instances.set_total_blocks(blocker, blocking)
+ else:
+ logger.debug("Skipping chaos.social, run ./fba.py fetch_cs instead!")
logger.info("Checking %d entries from blocker='%s',software='%s' ...", len(blocking), blocker, software)
blockdict = list()
raise ValueError(f"Parameter block_level[]='{type(block_level)}' is not of type 'str'")
elif block_level == "":
raise ValueError("Parameter 'block_level' is empty")
-
- if block_level == "silence":
+ elif block_level in ["accept", "accepted"]:
+ raise ValueError(f"Parameter block_level='{block_level}' is not accepted but function was invoked")
+ elif block_level == "silence":
logger.debug("Block level 'silence' has been changed to 'silenced'")
block_level = "silenced"
elif block_level == "suspend":
if blocked == "":
logger.debug("line[]='%s' returned empty blocked domain - SKIPPED!", type(line))
continue
- elif not domain_helper.is_wanted(blocked):
- logger.debug("blocked='%s' is not wanted - SKIPPED!", domain)
- continue
-
- logger.debug("blocked='%s',domain='%s' - BEFORE!", blocked, domain)
- blocked = utils.deobfuscate(blocked, domain)
-
- logger.debug("blocked[%s]='%s' - DEOBFUSCATED!", type(blocked), blocked)
- if not domain_helper.is_wanted(blocked):
- logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
- continue
logger.debug("Appending blocked='%s',reason='%s'", blocked, reason)
blocklist.append({
if blocked == "":
logger.warning("blocked='%s' is empty after tidyup.domain() - SKIPPED!", tag.contents[0])
continue
- elif not domain_helper.is_wanted(blocked):
- logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
- continue
logger.debug("Appending blocker='%s',blocked='%s',block_level='reject' ...", domain, blocked)
blocklist.append({
if peer == "":
logger.debug("peer is empty - SKIPPED!")
continue
- elif not domain_helper.is_wanted(peer):
- logger.debug("peer='%s' is not wanted - SKIPPED!", peer)
- continue
elif peer in peers:
logger.debug("peer='%s' already added - SKIPPED!", peer)
continue
if peer == "":
logger.debug("peer is empty - SKIPPED!")
continue
- elif not domain_helper.is_wanted(peer):
- logger.debug("peer='%s' is not wanted - SKIPPED!", peer)
- continue
elif peer in peers:
logger.debug("peer='%s' already added - SKIPPED!", peer)
continue
from fba.http import network
+from fba.models import blocks
from fba.models import instances
logging.basicConfig(level=logging.INFO)
elif "severity" not in block:
logger.warning("block()=%d does not contain element 'severity' - SKIPPED!", len(block))
continue
+ elif block["severity"] in ["accept", "accepted"]:
+ logger.debug("block[domain]='%s' has unwanted severity level '%s' - SKIPPED!", block["domain"], block["severity"])
+ continue
reason = tidyup.reason(block["comment"]) if "comment" in block and block["comment"] is not None and block["comment"] != "" else None
"blocked" : block["domain"],
"hash" : block["digest"],
"reason" : reason,
- "block_level": block["severity"]
+ "block_level": blocks.alias_block_level(block["severity"]),
})
else:
logger.debug("domain='%s' has no block list", domain)
elif not isinstance(row["host"], str):
logger.warning("row[host][]='%s' is not of type 'str' - SKIPPED!", type(row['host']))
continue
- elif not domain_helper.is_wanted(row["host"]):
- logger.debug("row[host]='%s' is not wanted, domain='%s' - SKIPPED!", row['host'], domain)
- continue
elif row["host"] in peers:
logger.debug("Not adding row[host]='%s', already found - SKIPPED!", row['host'])
continue
if blocked == "":
logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s' - SKIPPED!", domain, block_level)
continue
- elif not domain_helper.is_wanted(blocked):
- logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
- continue
logger.debug("Invoking utils.deobfuscate(%s, %s) ...", blocked, domain)
blocked = utils.deobfuscate(blocked, domain)
logger.debug("blocked='%s' - DEOBFUSCATED!", blocked)
- if not domain_helper.is_wanted(blocked):
- logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
- continue
logger.debug("Appending blocker='%s',blocked='%s',block_level='%s' ...", domain, blocked, block_level)
blockdict.append({
if blocked == "":
logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s'", domain, block_level)
continue
- elif not domain_helper.is_wanted(blocked):
- logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
- continue
-
- logger.debug("Invoking utils.deobfuscate(%s, %s) ...", blocked, domain)
- blocked = utils.deobfuscate(blocked, domain)
-
- logger.debug("blocked='%s' - DEOBFUSCATED!", blocked)
- if not domain_helper.is_wanted(blocked):
- logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
- continue
logger.debug("Appending blocker='%s',blocked='%s',block_level='%s' ...", domain, blocked, block_level)
blockdict.append({
if blocked == "":
logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s'", domain, block_level)
continue
- elif not domain_helper.is_wanted(blocked):
- logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
- continue
-
- logger.debug("Invoking utils.deobfuscate(%s, %s) ...", blocked, domain)
- blocked = utils.deobfuscate(blocked, domain)
- logger.debug("blocked='%s' - DEOBFUSCATED!", blocked)
logger.debug("Checking %d blockdict records ...", len(blockdict))
for block in blockdict:
elif blocked == "":
logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s'", domain, block_level)
continue
- elif not domain_helper.is_wanted(blocked):
- logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
- continue
-
- logger.debug("Invoking utils.deobfuscate(%s, %s) ...", blocked, domain)
- blocked = utils.deobfuscate(blocked, domain)
-
- logger.debug("blocked='%s' - DEOBFUSCATED!", blocked)
- if not domain_helper.is_wanted(blocked):
- logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
- continue
logger.debug("Checking %d blockdict records ...", len(blockdict))
for block in blockdict:
logger.debug("rows[%s]()=%d'", type(rows), len(rows))
for block in rows:
- logger.debug("Invoking utils.deobfuscate(%s, %s) ...", block["blocked"], domain)
- block["blocked"] = utils.deobfuscate(block["blocked"], domain)
-
- logger.debug("block[blocked]='%s' - DEOBFUSCATED!", block["blocked"])
- if not domain_helper.is_wanted(block["blocked"]):
- logger.debug("block[blocked]='%s' is not wanted - SKIPPED!", block["blocked"])
- continue
-
logger.debug("Appending blocker='%s',block[blocked]='%s',block[reason]='%s',block_level='%s' ...",domain, block["blocked"], block["reason"], block_level)
blockdict.append({
"blocker" : domain,
blocked = tidyup.domain(line.find_all("td")[0].text)
reason = tidyup.reason(line.find_all("td")[1].text)
+ if blocked is None or blocked == "":
+ logger.debug("blocker='%s',block_level='%s': blocked is empty - SKIPPED!", blocker, block_level)
+ continue
+
logger.debug("Appending block_level='%s',blocked='%s',reason='%s' ...", block_level, blocked, reason)
blocklist[block_level].append({
"blocked": blocked,