logger.warning("Exception '%s' during checking CSRF (fetch_peers,%s) - EXIT!", type(exception), __name__)
return list()
- domains = list()
try:
logger.debug("Fetching JSON from pixelfed.org API, headers()=%d ...", len(headers))
fetched = network.get_json_api(
logger.info("Adding new block: blocked='%s',block_level='%s'", blocked, block_level)
if utils.process_block("todon.eu", blocked, None, block_level) and block_level == "reject" and config.get("bot_enabled"):
- logger.debug("Appending blocked='%s',reason='%s' for blocker='todon.eu' ...", block["blocked"], block["block_level"])
+ logger.debug("Appending blocked='%s',reason='%s' for blocker='todon.eu' ...", blocked, block_level)
blockdict.append({
"blocked": blocked,
"reason" : None,
domains["reject"] = federation.find_domains(blocked)
logger.debug("domains[silenced]()=%d,domains[reject]()=%d", len(domains["silenced"]), len(domains["reject"]))
+ blockdict = list()
if len(domains) > 0:
locking.acquire()
logger.debug("Adding domain='%s',domains()=%d", domain, len(domains))
domains.append(domain)
- logger.debug("domains()='%d", len(domains))
+ logger.debug("domains()=%d", len(domains))
if len(domains) > 0:
locking.acquire()
response = utils.fetch_url(f"{base_url}/{block['csv_url']}", network.web_headers, (config.get("connection_timeout"), config.get("read_timeout")))
logger.debug("response.ok='%s',response.status_code=%d,response.text()=%d", response.ok, response.status_code, len(response.text))
- if response.ok and response.content != "":
- logger.debug("Fetched %d Bytes, parsing CSV ...", len(response.content))
- reader = csv.DictReader(response.content.decode('utf-8').splitlines(), dialect="unix")
+ if not response.ok or response.status_code > 399 or response.content == "":
+ logger.warning("Could not fetch csv_url='%s' for blocker='%s' - SKIPPED!", block["csv_url"], block["blocker"])
+ continue
- logger.debug("reader[]='%s'", type(reader))
- blockdict = list()
- for row in reader:
- logger.debug("row[%s]='%s'", type(row), row)
- domain = severity = None
- reject_media = reject_reports = False
- if "#domain" in row:
- domain = row["#domain"]
- elif "domain" in row:
- domain = row["domain"]
- else:
- logger.debug("row='%s' does not contain domain column", row)
- continue
+ logger.debug("Fetched %d Bytes, parsing CSV ...", len(response.content))
+ reader = csv.DictReader(response.content.decode('utf-8').splitlines(), dialect="unix")
- if "#severity" in row:
- severity = row["#severity"]
- elif "severity" in row:
- severity = row["severity"]
- else:
- logger.debug("row='%s' does not contain severity column", row)
- continue
+ logger.debug("reader[]='%s'", type(reader))
+ blockdict = list()
+ for row in reader:
+ logger.debug("row[%s]='%s'", type(row), row)
+ domain = severity = None
+ reject_media = reject_reports = False
+ if "#domain" in row:
+ domain = row["#domain"]
+ elif "domain" in row:
+ domain = row["domain"]
+ else:
+ logger.debug("row='%s' does not contain domain column", row)
+ continue
- if "#reject_media" in row and row["#reject_media"].lower() == "true":
- reject_media = True
- elif "reject_media" in row and row["reject_media"].lower() == "true":
- reject_media = True
+ if "#severity" in row:
+ severity = row["#severity"]
+ elif "severity" in row:
+ severity = row["severity"]
+ else:
+ logger.debug("row='%s' does not contain severity column", row)
+ continue
- if "#reject_reports" in row and row["#reject_reports"].lower() == "true":
- reject_reports = True
- elif "reject_reports" in row and row["reject_reports"].lower() == "true":
- reject_reports = True
+ if "#reject_media" in row and row["#reject_media"].lower() == "true":
+ reject_media = True
+ elif "reject_media" in row and row["reject_media"].lower() == "true":
+ reject_media = True
- logger.debug("domain='%s',severity='%s',reject_media='%s',reject_reports='%s'", domain, severity, reject_media, reject_reports)
- if not utils.is_domain_wanted(domain):
- logger.debug("domain='%s' is not wanted - SKIPPED!", domain)
- continue
+ if "#reject_reports" in row and row["#reject_reports"].lower() == "true":
+ reject_reports = True
+ elif "reject_reports" in row and row["reject_reports"].lower() == "true":
+ reject_reports = True
- logger.debug("Marking domain='%s' as handled", domain)
- domains.append(domain)
+ logger.debug("domain='%s',severity='%s',reject_media='%s',reject_reports='%s'", domain, severity, reject_media, reject_reports)
+ if not utils.is_domain_wanted(domain):
+ logger.debug("domain='%s' is not wanted - SKIPPED!", domain)
+ continue
- logger.debug("Processing domain='%s' ...", domain)
- processed = utils.process_domain(domain, block["blocker"], inspect.currentframe().f_code.co_name)
- logger.debug("processed='%s'", processed)
+ logger.debug("Marking domain='%s' as handled", domain)
+ domains.append(domain)
- if utils.process_block(block["blocker"], domain, None, "reject") and config.get("bot_enabled"):
- logger.debug("Appending blocked='%s',reason='%s' for blocker='%s' ...", domain, block["block_level"], block["blocker"])
- blockdict.append({
- "blocked": domain,
- "reason" : block["reason"],
- })
+ logger.debug("Processing domain='%s' ...", domain)
+ processed = utils.process_domain(domain, block["blocker"], inspect.currentframe().f_code.co_name)
+ logger.debug("processed='%s'", processed)
- if reject_media:
- utils.process_block(block["blocker"], domain, None, "reject_media")
- if reject_reports:
- utils.process_block(block["blocker"], domain, None, "reject_reports")
+ if utils.process_block(block["blocker"], domain, None, "reject") and config.get("bot_enabled"):
+ logger.debug("Appending blocked='%s',reason='%s' for blocker='%s' ...", domain, block["block_level"], block["blocker"])
+ blockdict.append({
+ "blocked": domain,
+ "reason" : block["reason"],
+ })
- logger.debug("Invoking commit() ...")
- database.connection.commit()
+ if reject_media:
+ utils.process_block(block["blocker"], domain, None, "reject_media")
+ if reject_reports:
+ utils.process_block(block["blocker"], domain, None, "reject_reports")
- if config.get("bot_enabled") and len(blockdict) > 0:
- logger.info("Sending bot POST for blocker='%s',blockdict()=%d ...", blocker, len(blockdict))
- network.send_bot_post(block["blocker"], blockdict)
+ logger.debug("Invoking commit() ...")
+ database.connection.commit()
+
+ if config.get("bot_enabled") and len(blockdict) > 0:
+ logger.info("Sending bot POST for blocker='%s',blockdict()=%d ...", block["blocker"], len(blockdict))
+ network.send_bot_post(block["blocker"], blockdict)
logger.debug("Success! - EXIT!")
return 0
continue
logger.info("Proccessing blocked='%s' ...", block["blocked"])
- processed = utils.process_domain(block["blocked"], "climatejustice.social", inspect.currentframe().f_code.co_name)
+ utils.process_domain(block["blocked"], "climatejustice.social", inspect.currentframe().f_code.co_name)
blockdict = list()
for blocker in domains:
logger.info("Checking %d block(s) from domain='%s' ...", len(blocking), row[0])
obfuscated = 0
+ blockdict = list()
for block in blocking:
logger.debug("blocked='%s'", block["blocked"])
blocked = None
block["block_level"] = "suspended"
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"):
- logger.debug("Appending blocked='%s',reason='%s' for blocker='%s' ...", block["blocked"], block["block_level"], blocker)
+ if utils.process_block(row[0], 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"], row[0])
blockdict.append({
"blocked": block["blocked"],
"reason" : block["reason"],
if obfuscated == 0 and len(blocking) > 0:
logger.info("Block list from domain='%s' has been fully deobfuscated.", row[0])
instances.set_has_obfuscation(row[0], False)
+
+ if instances.has_pending(row[0]):
+ logger.debug("Flushing updates for blocker='%s' ...", row[0])
instances.update_data(row[0])
+ logger.debug("Invoking commit() ...")
+ database.connection.commit()
+
+ if config.get("bot_enabled") and len(blockdict) > 0:
+ logger.info("Sending bot POST for blocker='%s,blockdict()=%d ...", row[0], len(blockdict))
+ network.send_bot_post(row[0], blockdict)
+
logger.debug("Success! - EXIT!")
return 0