import json
import logging
-from fba import csrf
-
from fba.helpers import config
from fba.helpers import dicts as dict_helper
from fba.helpers import domain as domain_helper
from fba.helpers import tidyup
+from fba.http import csrf
from fba.http import network
from fba.models import instances
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
+ elif not domain_helper.is_wanted(row["host"]):
+ logger.debug("row[host]='%s' is not wanted - SKIPPED!", row["host"])
+ continue
logger.debug("Adding peer: row[host]='%s'", row['host'])
added = added + 1
logger.debug("domain='%s' - CALLED!", domain)
domain_helper.raise_on(domain)
+ if not instances.is_registered(domain):
+ raise Exception(f"domain='{domain}' is not registered but function is invoked.")
+
# No CSRF by default, you don't have to add network.api_headers by yourself here
headers = tuple()
for instance in rows:
# Is it there?
logger.debug("instance[]='%s'", type(instance))
+ if "host" not in instance:
+ logger.warning("instance(%d)='%s' has no key 'host' - SKIPPED!", len(instance), instance)
+ continue
+ elif instance["host"] is None or instance["host"] == "":
+ logger.debug("instance[host]='%s' is None or empty - SKIPPED!", instance["host"])
+ continue
+
+ logger.debug("instance[host]='%s' - BEFORE!", instance["host"])
blocked = tidyup.domain(instance["host"])
- if "isSuspended" in instance and instance["isSuspended"] and not dict_helper.has_key(blocklist, "blocked", blocked):
+
+ logger.debug("blocked[%s]='%s' - AFTER!", type(blocked), blocked)
+ if blocked is None or blocked == "":
+ logger.warning("instance[host]='%s' is None or empty after tidyup.domain() - SKIPPED!", instance["host"])
+ continue
+ elif not domain_helper.is_wanted(blocked):
+ logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
+ continue
+ elif "isSuspended" in instance and instance["isSuspended"] and not dict_helper.has_key(blocklist, "blocked", blocked):
count = count + 1
logger.debug("Appending blocker='%s',blocked='%s',block_level='suspended'", domain, blocked)
blocklist.append({
# Is it there?
logger.debug("instance[]='%s'", type(instance))
blocked = tidyup.domain(instance["host"])
- if "isBlocked" in instance and instance["isBlocked"] and not dict_helper.has_key(blocklist, "blocked", blocked):
+
+ logger.debug("blocked='%s'", blocked)
+ if blocked is None or blocked == "":
+ logger.warning("instance[host]='%s' is None or empty after tidyup.domain() - SKIPPED!", instance["host"])
+ continue
+ elif not domain_helper.is_wanted(blocked):
+ logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
+ continue
+ elif "isBlocked" in instance and instance["isBlocked"] and not dict_helper.has_key(blocklist, "blocked", blocked):
count = count + 1
logger.debug("Appending blocker='%s',blocked='%s',block_level='reject'", domain, blocked)
blocklist.append({