"recheck_obfuscation",
help="Checks all instance's obfuscated peers if they can be de-obfuscated now.",
)
+ parser.add_argument("--domain", help="Instance name (aka. domain)")
+ parser.add_argument("--software", help="Name of software, e.g. 'lemmy'")
parser.set_defaults(command=commands.recheck_obfuscation)
### Fetch blocks from registered instances or given ###
except network.exceptions as exception:
logger.warning("Exception '%s' during fetching instances (fetch_bkali) from domain='%s'", type(exception), domain)
instances.set_last_error(domain, exception)
+ return 100
logger.debug("Success - EXIT!")
return 0
logger.debug("Hash wasn't found, adding: blocked='%s',blocker='%s'", block["blocked"], blocker)
federation.fetch_instances(block["blocked"], blocker, None, inspect.currentframe().f_code.co_name)
- if block["block_level"] == "silence":
- logger.debug("Block level 'silence' has been changed to 'silenced'")
- block["block_level"] = "silenced"
- elif block["block_level"] == "suspend":
- logger.debug("Block level 'suspend' has been changed to 'suspended'")
- block["block_level"] = "suspended"
+ block["block_level"] = utils.alias_block_level(block["block_level"])
if utils.process_block(blocker, block["blocked"], block["reason"], block["block_level"]) and block["block_level"] == "reject" and config.get("bot_enabled"):
logger.debug("Appending blocked='%s',reason='%s' for blocker='%s' ...", block["blocked"], block["block_level"], blocker)
except network.exceptions as exception:
logger.warning("Exception '%s' during fetching instances (fetch_fba_rss) from domain='%s'", type(exception), domain)
instances.set_last_error(domain, exception)
+ return 100
logger.debug("Success! - EXIT!")
return 0
except network.exceptions as exception:
logger.warning("Exception '%s' during fetching instances (fetch_fbabot_atom) from domain='%s'", type(exception), domain)
instances.set_last_error(domain, exception)
+ return 100
logger.debug("Success! - EXIT!")
return 0
locking.acquire()
- database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE has_obfuscation = 1")
+ if args.domain != "" and utils.is_domain_wanted(args.domain):
+ database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE has_obfuscation = 1 AND domain = ?", [args.domain])
+ elif args.domain != "" and validators.domain(args.software) == args.software:
+ database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE has_obfuscation = 1 AND software = ?", [args.software])
+ else:
+ database.cursor.execute("SELECT domain, software, nodeinfo_url FROM instances WHERE has_obfuscation = 1")
+
rows = database.cursor.fetchall()
logger.info("Checking %d domains ...", len(rows))
for row in rows:
logger.debug("blocked='%s' is already blocked - SKIPPED!", block["blocked"])
continue
+ logger.debug("blocked[%s]='%s',block[blocked]='%s'", type(blocked), blocked, block["blocked"])
if blocked is not None and blocked != block["blocked"]:
logger.debug("blocked='%s' was deobfuscated to blocked='%s'", block["blocked"], blocked)
obfuscated = obfuscated - 1
logger.debug("blocked='%s' is already blocked by domain='%s' - SKIPPED!", blocked, row[0])
continue
- if block["block_level"] == "silence":
- logger.debug("Block level 'silence' has been changed to 'silenced'")
- block["block_level"] = "silenced"
- elif block["block_level"] == "suspend":
- logger.debug("Block level 'suspend' has been changed to 'suspended'")
- block["block_level"] = "suspended"
+ block["block_level"] = utils.alias_block_level(block["block_level"])
logger.info("blocked='%s' has been deobfuscated to blocked='%s', adding ...", block["blocked"], blocked)
if utils.process_block(row[0], blocked, block["reason"], block["block_level"]) and block["block_level"] == "reject" and config.get("bot_enabled"):
except network.exceptions as exception:
logger.warning("Exception '%s' during checking CSRF (fetch_blocks,%s) - EXIT!", type(exception), __name__)
instances.set_last_error(domain, exception)
- return blocklist
+ return list()
try:
# json endpoint for newer mastodongs
except network.exceptions as exception:
logger.warning("Exception '%s' during checking CSRF (fetch_blocks,%s) - EXIT!", type(exception), __name__)
instances.set_last_error(domain, exception)
- return blocklist
+ return list()
# iterating through all "suspended" (follow-only in its terminology)
# instances page-by-page since it doesn't support sending them all at once
logger.warning("rows()=%d does not have key 'metadata', domain='%s'", len(rows), domain)
return list()
elif "federation" not in rows["metadata"]:
- logger.warning("rows()=%d does not have key 'federation', domain='%s'", len(rows['metadata']), domain)
+ logger.warning("rows()=%d does not have key 'federation', domain='%s'", len(rows["metadata"]), domain)
return list()
data = rows["metadata"]["federation"]
elif block_level == "accept":
logger.debug("domain='%s' skipping block_level='accept'", domain)
continue
- elif block_level == "suspend":
- logger.debug("domain='%s', mapping 'suspend' to 'suspended'", domain)
- block_level = "suspended"
- elif block_level == "silence":
- logger.debug("domain='%s', mapping 'silence' to 'silenced'", domain)
- block_level = "silenced"
+
+ block_level = utils.alias_block_level(block_level)
logger.debug("Checking %d entries from domain='%s',block_level='%s' ...", len(blocklist), domain, block_level)
if len(blocklist) > 0:
logger.warning("block_level is now empty!")
continue
elif block_level == "accept":
- logger.debug("domain='%s' skipping block_level='accept'", domain)
+ logger.debug("domain='%s': Skipping block_level='%s' ...", domain, block_level)
continue
- elif block_level == "suspend":
- logger.debug("domain='%s', mapping 'suspend' to 'suspended'", domain)
- block_level = "suspended"
- elif block_level == "silence":
- logger.debug("domain='%s', mapping 'silence' to 'silenced'", domain)
- block_level = "silenced"
+
+ block_level = utils.alias_block_level(block_level)
logger.debug("Checking %d entries from domain='%s',block_level='%s' ...", len(info.items()), domain, block_level)
for blocked, reason in info.items():
logger.debug("added='%s' - EXIT!", added)
return added
-
\ No newline at end of file
+
+def alias_block_level(block_level: str) -> str:
+ logger.debug("block_level='%s' - CALLED!", block_level)
+ if not isinstance(block_level, str):
+ raise ValueError(f"Parameter block_level[]='%s' is not of type 'str'", type(block_level))
+ elif block_level == "":
+ raise ValueError("Parameter 'block_level' is empty")
+
+ if block_level == "silence":
+ logger.debug("Block level 'silence' has been changed to 'silenced'")
+ block_level = "silenced"
+ elif block_level == "suspend":
+ logger.debug("Block level 'suspend' has been changed to 'suspended'")
+ block_level = "suspended"
+
+ logger.debug("block_level='%s' - EXIT!", block_level)
+ return block_level