logger.debug("block_level='%s' - CALLED!", block_level)
if not isinstance(block_level, str):
- raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
+ raise TypeError(f"Parameter block_level[]='{type(block_level)}' is not of expected type 'str'")
elif block_level in ["accept", "accepted"]:
raise RuntimeError(f"Parameter block_level='{block_level}' is 'accept(ed)' but function was invoked")
elif block_level == "silence":
logger.debug("key='%s',rows()=%d,value[]='%s' - CALLED!", key, len(rows), type(value))
if not isinstance(key, str):
- raise TypeError(f"Parameter key[]='{type(key)}' has not expected type 'str'")
+ raise TypeError(f"Parameter key[]='{type(key)}' is not of expected type 'str'")
elif not key_exists(key):
logger.debug("Cache for key='%s' not initialized.", key)
_cache[key] = {}
logger.debug("key='%s',sub='%s',value[]='%s' - CALLED!", key, sub, type(value))
if not isinstance(key, str):
- raise TypeError(f"Parameter key[]='{type(key)}' has not expected type 'str'")
+ raise TypeError(f"Parameter key[]='{type(key)}' is not of expected type 'str'")
elif not isinstance(sub, str):
- raise TypeError(f"Parameter sub[]='{type(sub)}' has not expected type 'str'")
+ raise TypeError(f"Parameter sub[]='{type(sub)}' is not of expected type 'str'")
elif not key_exists(key):
raise KeyError(f"Cache for key='{key}' is not initialized, but function invoked")
logger.debug("key='%s',sub='%s' - CALLED!", key, sub)
if not isinstance(key, str):
- raise TypeError(f"Parameter key[]='{type(key)}' has not expected type 'str'")
+ raise TypeError(f"Parameter key[]='{type(key)}' is not of expected type 'str'")
elif not isinstance(sub, str):
- raise TypeError(f"Parameter sub[]='{type(sub)}' has not expected type 'str'")
+ raise TypeError(f"Parameter sub[]='{type(sub)}' is not of expected type 'str'")
elif not key_exists(key):
raise KeyError(f"Cache for key='{key}' is not initialized, but function invoked")
logger.debug("key[%s]='%s' - CALLED!", type(key), key)
if not isinstance(key, str):
- raise TypeError(f"Parameter key[]='{type(key)}' has not expected type 'str'")
+ raise TypeError(f"Parameter key[]='{type(key)}' is not of expected type 'str'")
elif key == "":
raise ValueError("Parameter 'key' is an empty string")
elif not key in _config:
if blacklist.is_blacklisted(domain):
raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(cookies, dict):
- raise TypeError(f"Parameter cookies[]='{type(cookies)}' has not expected type 'dict'")
+ raise TypeError(f"Parameter cookies[]='{type(cookies)}' is not of expected type 'dict'")
logger.debug("Setting %d cookie(s) for domain='%s'", len(cookies), domain)
_cookies[domain] = cookies
logger.debug("lists()=%d,key='%s',value[]='%s' - CALLED!", len(lists), key, type(value))
if not isinstance(lists, list):
- raise TypeError(f"Parameter lists[]='{type(lists)}' has not expected type 'list'")
+ raise TypeError(f"Parameter lists[]='{type(lists)}' is not of expected type 'list'")
elif not isinstance(key, str):
- raise TypeError(f"Parameter key[]='{type(key)}' has not expected type 'str'")
+ raise TypeError(f"Parameter key[]='{type(key)}' is not of expected type 'str'")
elif key == "":
raise ValueError("Parameter 'key' is an empty string")
logger.debug("row[%s]='%s", type(row), row)
if not isinstance(row, dict):
- raise TypeError(f"row[]='{type(row)}' has not expected type 'dict'")
+ raise TypeError(f"row[]='{type(row)}' is not of expected type 'dict'")
elif not key in row:
raise KeyError(f"Cannot find key='{key}'")
elif row[key] == value:
logger.debug("domain='%s' - CALLED!", domain)
if not isinstance(domain, str):
- raise TypeError(f"Parameter domain[]='{type(domain)}' has not expected type 'str'")
+ raise TypeError(f"Parameter domain[]='{type(domain)}' is not of expected type 'str'")
elif domain == "":
raise ValueError("Parameter 'domain' is an empty string")
elif domain.lower() != domain:
if blacklist.is_blacklisted(domain):
raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(url, str):
- raise TypeError(f"Parameter url[]='{type(url)}' has not expected type 'str'")
+ raise TypeError(f"Parameter url[]='{type(url)}' is not of expected type 'str'")
elif url == "":
raise ValueError("Parameter 'url' is an empty string")
elif not validators.url(url):
logger.debug("domain='%s' - CALLED!", domain)
if not isinstance(domain, str):
- raise TypeError(f"Parameter domain[]='{type(domain)}' has not expected type 'str'")
+ raise TypeError(f"Parameter domain[]='{type(domain)}' is not of expected type 'str'")
elif domain == "":
raise ValueError("Parameter 'domain' is an empty string")
logger.debug("domain='%s' - CALLED!", domain)
if not isinstance(domain, str):
- raise TypeError(f"Parameter domain[]='{type(domain)}' has not expected type 'str'")
+ raise TypeError(f"Parameter domain[]='{type(domain)}' is not of expected type 'str'")
elif domain == "":
raise ValueError("Parameter 'domain' is an empty string")
domain_helper.raise_on(blocker)
if not isinstance(command, str):
- raise TypeError(f"Parameter command[]='{type(command)}' has not expected type 'str'")
+ raise TypeError(f"Parameter command[]='{type(command)}' is not of expected type 'str'")
elif command == "":
raise ValueError("Parameter 'command' is an empty string")
elif blacklist.is_blacklisted(blocked):
elif blacklist.is_blacklisted(blocker):
raise RuntimeError(f"blocker='{blocker}' is blacklisted but function was invoked")
- logger.debug("blocked='%s' - BEFORE!", blocked)
- blocked = utils.deobfuscate(blocked, blocker)
- logger.debug("blocked='%s' - AFTER!", blocked)
+ if blocked.find("*") >= 0 or blocked.find("?") >= 0:
+ logger.debug("blocked='%s' - BEFORE!", blocked)
+ blocked = utils.deobfuscate(blocked, blocker)
+ logger.debug("blocked='%s' - AFTER!", blocked)
logger.debug("Checking if blocker='%s' has pending data ...", blocker)
if instances.is_registered(blocker) and instances.has_pending(blocker):
domain_helper.raise_on(blocked)
if not isinstance(reason, str) and reason is not None:
- raise TypeError(f"Parameter reason[]='{type(reason)}' has not expected type 'str'")
+ raise TypeError(f"Parameter reason[]='{type(reason)}' is not of expected type 'str'")
elif not isinstance(block_level, str):
- raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
+ raise TypeError(f"Parameter block_level[]='{type(block_level)}' is not of expected type 'str'")
elif block_level == "":
raise ValueError("Parameter block_level is empty")
elif block_level in ["reject", "suspend", "accept", "silence", "nsfw", "quarantined_instances"]:
domain_helper.raise_on(blocker)
if not isinstance(url, str):
- raise TypeError(f"url[]='{url}' has not expected type 'str'")
+ raise TypeError(f"url[]='{url}' is not of expected type 'str'")
elif url in [None, ""]:
raise ValueError("Parameter 'url' is an empty string")
elif not validators.url(url):
raise ValueError(f"Parameter url='{url}' is not a valid URL")
elif not isinstance(command, str):
- raise TypeError(f"command[]='{command}' has not expected type 'str'")
+ raise TypeError(f"command[]='{command}' is not of expected type 'str'")
elif command == "":
raise ValueError("Parameter 'command' is an empty string")
elif blacklist.is_blacklisted(blocker):
elif "severity" in row:
severity = blocks_helper.alias_block_level(row["severity"])
else:
- logger.debug("row='%s' does not contain severity column, setting 'reject'", row)
+ logger.debug("row='%s' does not contain severity column, setting 'rejected'", row)
severity = "rejected"
if "reason" in row and row["reason"] not in [None, ""]:
logger.debug("domain='%s' has an unwanted TLD - SKIPPED!", domain)
continue
elif domain.find("*") >= 0 or domain.find("?") >= 0:
- logger.debug("domain='%s' is obfuscated - Invoking utils.deobfuscate(%s, %s) ...", domain, domain, blocker)
+ logger.debug("domain='%s' - BEFORE!", domain)
domain = utils.deobfuscate(domain, blocker)
logger.debug("domain='%s' - AFTER!", domain)
domain_helper.raise_on(instance)
if not isinstance(url, str):
- raise TypeError(f"url[]='{url}' has not expected type 'str'")
+ raise TypeError(f"url[]='{url}' is not of expected type 'str'")
elif url in [None, ""]:
raise ValueError("Parameter 'url' is an empty string")
elif not validators.url(url):
raise ValueError(f"Parameter url='{url}' is not a valid URL")
elif not isinstance(command, str):
- raise TypeError(f"command[]='{command}' has not expected type 'str'")
+ raise TypeError(f"command[]='{command}' is not of expected type 'str'")
elif command == "":
raise ValueError("Parameter 'command' is an empty string")
elif blacklist.is_blacklisted(instance):
logger.debug("domain='%s' has an unwanted TLD - SKIPPED!", domain)
continue
elif domain.find("*") >= 0 or domain.find("?") >= 0:
- logger.debug("domain='%s' is obfuscated - Invoking utils.deobfuscate(%s, %s) ...", domain, domain, instance)
+ logger.debug("domain='%s' - BEFORE!", domain)
domain = utils.deobfuscate(domain, instance)
logger.debug("domain='%s' - AFTER!", domain)
logger.debug("software='%s' - CALLED!", software)
if not isinstance(software, str):
- raise TypeError(f"Parameter software[]='{type(software)}' has not expected type 'str'")
+ raise TypeError(f"Parameter software[]='{type(software)}' is not of expected type 'str'")
elif software == "":
raise ValueError("Parameter 'software' is an empty string")
elif "hosted on" not in software:
logger.debug("software='%s' - CALLED!", software)
if not isinstance(software, str):
- raise TypeError(f"Parameter software[]='{type(software)}' has not expected type 'str'")
+ raise TypeError(f"Parameter software[]='{type(software)}' is not of expected type 'str'")
elif software == "":
raise ValueError("Parameter 'software' is an empty string")
elif "powered by" not in software:
logger.debug("software='%s',until='%s' - CALLED!", software, until)
if not isinstance(software, str):
- raise TypeError(f"Parameter software[]='{type(software)}' has not expected type 'str'")
+ raise TypeError(f"Parameter software[]='{type(software)}' is not of expected type 'str'")
elif software == "":
raise ValueError("Parameter 'software' is an empty string")
elif not isinstance(until, str):
- raise TypeError(f"Parameter until[]='{type(until)}' has not expected type 'str'")
+ raise TypeError(f"Parameter until[]='{type(until)}' is not of expected type 'str'")
elif until == "":
raise ValueError("Parameter 'until' is an empty string")
elif not until in software:
logger.debug("string='%s' - CALLED!", string)
if not isinstance(string, str):
- raise TypeError(f"Parameter string[]='{type(string)}' has not expected type 'str'")
+ raise TypeError(f"Parameter string[]='{type(string)}' is not of expected type 'str'")
# Strip string
string = string.strip()
logger.debug("string='%s' - CALLED!", string)
if not isinstance(string, str):
- raise TypeError(f"Parameter string[]='{type(string)}' has not expected type 'str'")
+ raise TypeError(f"Parameter string[]='{type(string)}' is not of expected type 'str'")
elif string == "":
raise ValueError("Parameter 'string' is an empty string")
if blacklist.is_blacklisted(domain):
raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(headers, dict):
- raise TypeError(f"Parameter headers[]='{type(headers)}' has not expected type 'dict'")
+ raise TypeError(f"Parameter headers[]='{type(headers)}' is not of expected type 'dict'")
# Default headers with no CSRF
reqheaders = headers
if blacklist.is_blacklisted(domain):
raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(origin, str) and origin is not None:
- raise TypeError(f"Parameter origin[]='{type(origin)}' has not expected type 'str'")
+ raise TypeError(f"Parameter origin[]='{type(origin)}' is not of expected type 'str'")
elif not isinstance(command, str):
- raise TypeError(f"Parameter command[]='{type(command)}' has not expected type 'str'")
+ raise TypeError(f"Parameter command[]='{type(command)}' is not of expected type 'str'")
elif command == "":
raise ValueError("Parameter 'command' is an empty string")
elif command in ["fetch_blocks", "fetch_cs", "fetch_bkali", "fetch_relays", "fetch_fedipact", "fetch_joinmobilizon", "fetch_joinmisskey", "fetch_joinfediverse", "fetch_relaylist"] and origin is None:
raise ValueError(f"Parameter command='{command}' but origin is None, please fix invoking this function.")
elif not isinstance(path, str) and path is not None:
- raise TypeError(f"Parameter path[]='{type(path)}' has not expected type 'str'")
+ raise TypeError(f"Parameter path[]='{type(path)}' is not of expected type 'str'")
elif path is not None and not path.startswith("/"):
raise ValueError(f"path='{path}' does not start with a slash")
elif _DEPTH > 0 and instances.is_recent(domain, "last_instance_fetch"):
elif software is None:
logger.debug("domain='%s' has unknown software or nodeinfo has recently being fetched", domain)
elif not isinstance(software, str):
- raise TypeError(f"Parameter software[]='{type(software)}' has not expected type 'str'")
+ raise TypeError(f"Parameter software[]='{type(software)}' is not of expected type 'str'")
logger.debug("domain='%s' - BEFORE!", domain)
instance = domain_helper.encode_idna(domain.split("?")[0])
if blacklist.is_blacklisted(domain):
raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(software, str) and software is not None:
- raise TypeError(f"Parameter software[]='{type(software)}' has not expected type 'str'")
+ raise TypeError(f"Parameter software[]='{type(software)}' is not of expected type 'str'")
elif isinstance(software, str) and software == "":
raise ValueError("Parameter 'software' is an empty string")
elif software is not None and software_helper.is_relay(software):
raise RuntimeError(f"domain='{domain}' is of software='{software}' and isn't supported here.")
elif not isinstance(origin, str) and origin is not None:
- raise TypeError(f"Parameter origin[]='{type(origin)}' has not expected type 'str'")
+ raise TypeError(f"Parameter origin[]='{type(origin)}' is not of expected type 'str'")
elif isinstance(origin, str) and origin == "":
raise ValueError("Parameter 'origin' is an empty string")
logger.debug("peers[]='%s'", type(peers))
if not isinstance(peers, list):
- logger.warning("peers[]='%s' has not expected type 'list', maybe bad API response?", type(peers))
+ logger.warning("peers[]='%s' is not of expected type 'list', maybe bad API response?", type(peers))
peers = []
logger.debug("Invoking instances.set_total_peers(%s,%d) ...", domain, len(peers))
if blacklist.is_blacklisted(domain):
raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(path, str):
- raise TypeError(f"path[]='{type(path)}' has not expected type 'str'")
+ raise TypeError(f"path[]='{type(path)}' is not of expected type 'str'")
elif path == "":
raise ValueError("Parameter 'path' is an empty string")
elif not path.startswith("/"):
if blacklist.is_blacklisted(domain):
raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(path, str) and path is not None:
- raise TypeError(f"Parameter path[]='{type(path)}' has not expected type 'str'")
+ raise TypeError(f"Parameter path[]='{type(path)}' is not of expected type 'str'")
elif path is not None and not path.startswith("/"):
raise ValueError(f"path='{path}' does not start with a slash")
logger.debug("rows[]='%s' - CALLED!", type(rows))
if not isinstance(rows, dict):
- raise TypeError(f"Parameter rows[]='{type(rows)}' has not expected type 'dict'")
+ raise TypeError(f"Parameter rows[]='{type(rows)}' is not of expected type 'dict'")
elif len(rows) == 0:
raise ValueError("Parameter 'rows' is an empty string")
if blacklist.is_blacklisted(domain):
raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(path, str):
- raise TypeError(f"path[]='{type(path)}' has not expected type 'str'")
+ raise TypeError(f"path[]='{type(path)}' is not of expected type 'str'")
elif path == "":
raise ValueError("Parameter 'path' is empty")
elif not path.startswith("/"):
raise ValueError(f"path='{path}' does not start with / but should")
elif not isinstance(data, str):
- raise TypeError(f"data[]='{type(data)}' has not expected type 'str'")
+ raise TypeError(f"data[]='{type(data)}' is not of expected type 'str'")
elif headers is not None and not isinstance(headers, dict):
- raise ValueError(f"headers[]='{type(headers)}' has not expected type 'dict'")
+ raise ValueError(f"headers[]='{type(headers)}' is not of expected type 'dict'")
json_reply = {
"status_code": 200,
logger.debug("url='%s',timeout()=%d - CALLED!", url, len(timeout))
if not isinstance(url, str):
- raise TypeError(f"Parameter url[]='{type(url)}' has not expected type 'str'")
+ raise TypeError(f"Parameter url[]='{type(url)}' is not of expected type 'str'")
elif url == "":
raise ValueError("Parameter 'url' is an empty string")
elif not validators.url(url):
raise ValueError(f"Parameter url='{url}' is not a valid URL")
elif not isinstance(timeout, tuple):
- raise TypeError(f"timeout[]='{type(timeout)}' has not expected type 'tuple'")
+ raise TypeError(f"timeout[]='{type(timeout)}' is not of expected type 'tuple'")
json_reply = {
"status_code": 200,
if blacklist.is_blacklisted(domain):
raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(path, str):
- raise TypeError(f"path[]='{type(path)}' has not expected type 'str'")
+ raise TypeError(f"path[]='{type(path)}' is not of expected type 'str'")
elif path == "":
raise ValueError("Parameter 'path' is empty")
elif not path.startswith("/"):
raise ValueError(f"path='{path}' does not start with / but should")
elif not isinstance(headers, dict):
- raise TypeError(f"headers[]='{type(headers)}' has not expected type 'list'")
+ raise TypeError(f"headers[]='{type(headers)}' is not of expected type 'list'")
elif not isinstance(timeout, tuple):
- raise TypeError(f"timeout[]='{type(timeout)}' has not expected type 'tuple'")
+ raise TypeError(f"timeout[]='{type(timeout)}' is not of expected type 'tuple'")
json_reply = {
"status_code": 200,
if blacklist.is_blacklisted(domain):
raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(blocklist, list):
- raise TypeError(f"Parameter blocklist[]='{type(blocklist)}' has not expected type 'list'")
+ raise TypeError(f"Parameter blocklist[]='{type(blocklist)}' is not of expected type 'list'")
elif len(blocklist) == 0:
raise ValueError("Parameter 'blocklist' is an empty string")
elif config.get("bot_token") == "":
if blacklist.is_blacklisted(domain):
raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(path, str):
- raise TypeError(f"Parameter path[]='{type(path)}' has not expected type 'str'")
+ raise TypeError(f"Parameter path[]='{type(path)}' is not of expected type 'str'")
elif path == "":
raise ValueError("Parameter 'path' is an empty string")
elif not path.startswith("/"):
raise ValueError(f"path='{path}' does not start with / but should")
elif not isinstance(headers, dict):
- raise TypeError(f"headers[]='{type(headers)}' has not expected type 'dict'")
+ raise TypeError(f"headers[]='{type(headers)}' is not of expected type 'dict'")
elif not isinstance(timeout, tuple):
- raise TypeError(f"timeout[]='{type(timeout)}' has not expected type 'tuple'")
+ raise TypeError(f"timeout[]='{type(timeout)}' is not of expected type 'tuple'")
elif not isinstance(allow_redirects, bool):
- raise TypeError(f"allow_redirects[]='{type(allow_redirects)}' has not expected type 'bool'")
+ raise TypeError(f"allow_redirects[]='{type(allow_redirects)}' is not of expected type 'bool'")
start = 0
try:
logger.debug("url='%s',headers()=%d,timeout(%d)='%s',allow_redirects='%s' - CALLED!", url, len(headers), len(timeout), timeout, allow_redirects)
if not isinstance(url, str):
- raise TypeError(f"Parameter url[]='{type(url)}' has not expected type 'str'")
+ raise TypeError(f"Parameter url[]='{type(url)}' is not of expected type 'str'")
elif url == "":
raise ValueError("Parameter 'url' is an empty string")
elif not validators.url(url):
raise ValueError(f"Parameter url='{url}' is not a valid URL")
elif not isinstance(headers, dict):
- raise TypeError(f"Parameter headers[]='{type(headers)}' has not expected type 'dict'")
+ raise TypeError(f"Parameter headers[]='{type(headers)}' is not of expected type 'dict'")
elif not isinstance(timeout, tuple):
- raise TypeError(f"Parameter timeout[]='{type(timeout)}' has not expected type 'tuple'")
+ raise TypeError(f"Parameter timeout[]='{type(timeout)}' is not of expected type 'tuple'")
elif not isinstance(allow_redirects, bool):
- raise TypeError(f"Parameter allow_redirects[]='{type(allow_redirects)}' has not expected type 'bool'")
+ raise TypeError(f"Parameter allow_redirects[]='{type(allow_redirects)}' is not of expected type 'bool'")
logger.debug("Parsing url='%s' ...", url)
components = urllib.parse.urlparse(url)
logger.debug("hostname='%s',path='%s',headers()=%d,rows_key='%s' - CALLED!", hostname, path, len(headers), rows_key)
if not isinstance(hostname, str):
- raise TypeError(f"hostname[]='{type(hostname)}' has not expected type 'str'")
+ raise TypeError(f"hostname[]='{type(hostname)}' is not of expected type 'str'")
elif hostname == "":
raise ValueError("Parameter 'hostname' is an empty string")
elif not validators.hostname(hostname):
raise ValueError(f"hostname='{hostname}' is not a valid hostname")
elif not isinstance(path, str):
- raise TypeError(f"path[]='{type(path)}' has not expected type 'str'")
+ raise TypeError(f"path[]='{type(path)}' is not of expected type 'str'")
elif path == "":
raise ValueError("Parameter 'path' is an empty string")
elif not path.startswith("/"):
raise ValueError(f"path='{path}' does not start with a slash")
elif headers is not None and not isinstance(headers, dict):
- raise ValueError(f"headers[]='{type(headers)}' has not expected type 'dict'")
+ raise ValueError(f"headers[]='{type(headers)}' is not of expected type 'dict'")
elif not isinstance(rows_key, str) and rows_key is not None:
- raise TypeError(f"rows_key[]='{type(rows_key)}' has not expected type 'str'")
+ raise TypeError(f"rows_key[]='{type(rows_key)}' is not of expected type 'str'")
elif rows_key is not None and rows_key == "":
raise ValueError("Parameter 'rows_key' is an empty string")
logger.debug("url='%s' - CALLED!", url)
if not isinstance(url, str):
- raise TypeError(f"url[]='{type(url)}' has not expected type 'str'")
+ raise TypeError(f"url[]='{type(url)}' is not of expected type 'str'")
elif url == "":
raise ValueError("Parameter 'url' is an empty string")
elif not validators.url(url):
if blacklist.is_blacklisted(domain):
raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(path, str):
- raise TypeError(f"Parameter path[]='{type(path)}' has not expected type 'str'")
+ raise TypeError(f"Parameter path[]='{type(path)}' is not of expected type 'str'")
elif path == "":
raise ValueError("Parameter 'path' is an empty string")
elif not path.startswith("/"):
raise ValueError(f"path='{path}' does not start with / but should")
elif not isinstance(allow_redirects, bool):
- raise TypeError(f"allow_redirects[]='{type(allow_redirects)}' has not expected type 'bool'")
+ raise TypeError(f"allow_redirects[]='{type(allow_redirects)}' is not of expected type 'bool'")
logger.debug("Fetching path='%s' from domain='%s' ...", path, domain)
response = _fetch_response(
if blacklist.is_blacklisted(domain):
raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(path, str) and path is not None:
- raise TypeError(f"Parameter path[]='{type(path)}' has not expected type 'str'")
+ raise TypeError(f"Parameter path[]='{type(path)}' is not of expected type 'str'")
elif path is not None and not path.startswith("/"):
raise ValueError(f"path='{path}' does not start with a slash")
elif not isinstance(update_mode, bool) and update_mode is not None:
- raise TypeError(f"Parameter update_mode[]='{type(update_mode)}' has not expected type 'bool'")
+ raise TypeError(f"Parameter update_mode[]='{type(update_mode)}' is not of expected type 'bool'")
if path is None and update_mode:
logger.debug("Fetching well-known nodeinfo from domain='%s' ...", domain)
for link in infos["links"]:
logger.debug("link[%s]='%s'", type(link), link)
if not isinstance(link, dict) or not "rel" in link:
- logger.debug("link[]='%s' has not expected type 'dict' or no element 'rel' found - SKIPPED!", type(link))
+ logger.debug("link[]='%s' is not of expected type 'dict' or no element 'rel' found - SKIPPED!", type(link))
continue
elif link["rel"] != niid:
logger.debug("link[re]='%s' does not matched niid='%s' - SKIPPED!", link["rel"], niid)
domain_helper.raise_on(blocked)
if not isinstance(block_level, str):
- raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
+ raise TypeError(f"Parameter block_level[]='{type(block_level)}' is not of expected type 'str'")
elif block_level == "":
raise ValueError("Parameter 'block_level' is an empty string")
elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
domain_helper.raise_on(blocked)
if not isinstance(reason, str) and reason is not None:
- raise TypeError(f"Parameter reason[]='{type(reason)}' has not expected type 'str'")
+ raise TypeError(f"Parameter reason[]='{type(reason)}' is not of expected type 'str'")
elif not isinstance(block_level, str):
- raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
+ raise TypeError(f"Parameter block_level[]='{type(block_level)}' is not of expected type 'str'")
elif block_level == "":
raise ValueError("Parameter 'block_level' is an empty string")
elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
domain_helper.raise_on(blocked)
if not isinstance(block_level, str):
- raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
+ raise TypeError(f"Parameter block_level[]='{type(block_level)}' is not of expected type 'str'")
elif block_level == "":
raise ValueError("Parameter 'block_level' is an empty string")
elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
domain_helper.raise_on(blocked)
if not isinstance(block_level, str) and block_level is not None:
- raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
+ raise TypeError(f"Parameter block_level[]='{type(block_level)}' is not of expected type 'str'")
elif block_level == "":
raise ValueError("Parameter 'block_level' is an empty string")
elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
domain_helper.raise_on(blocked)
if not isinstance(block_level, str):
- raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
+ raise TypeError(f"Parameter block_level[]='{type(block_level)}' is not of expected type 'str'")
elif block_level == "":
raise ValueError("Parameter 'block_level' is an empty string")
elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
logger.debug("value='%s',column='%s' - CALLED!", value, column)
if not isinstance(value, str):
- raise TypeError(f"Parameter value[]='{type(value)}' has not expected type 'str'")
+ raise TypeError(f"Parameter value[]='{type(value)}' is not of expected type 'str'")
elif value == "":
raise ValueError("Parameter 'value' is an empty string")
elif not isinstance(column, str):
- raise TypeError(f"Parameter column[]='{type(column)}' has not expected type 'str'")
+ raise TypeError(f"Parameter column[]='{type(column)}' is not of expected type 'str'")
elif column == "":
raise ValueError("Parameter 'column' is an empty string")
logger.debug("rows[]='%s',column='%s' - CALLED!", type(rows), column)
if not isinstance(rows, list):
- raise TypeError(f"rows[]='{type(rows)}' has not expected type 'list'")
+ raise TypeError(f"rows[]='{type(rows)}' is not of expected type 'list'")
elif len(rows) == 0:
raise ValueError("Parameter 'rows' is an empty list")
elif not isinstance(column, str):
- raise TypeError(f"column='{type(column)}' has not expected type 'str'")
+ raise TypeError(f"column='{type(column)}' is not of expected type 'str'")
elif column not in ["blocker", "blocked"]:
raise ValueError(f"column='{column}' is not supported")
domain_helper.raise_on(domain)
if not isinstance(key, str):
- raise TypeError(f"Parameter key[]='{type(key)}' has not expected type 'str'")
+ raise TypeError(f"Parameter key[]='{type(key)}' is not of expected type 'str'")
elif key == "":
raise ValueError("Parameter 'key' is empty")
elif not key in _pending:
domain_helper.raise_on(domain)
if not isinstance(origin, str) and origin is not None:
- raise TypeError(f"origin[]='{type(origin)}' has not expected type 'str'")
+ raise TypeError(f"origin[]='{type(origin)}' is not of expected type 'str'")
elif origin == "":
raise ValueError("Parameter 'origin' is empty")
elif not isinstance(command, str):
- raise TypeError(f"command[]='{type(command)}' has not expected type 'str'")
+ raise TypeError(f"command[]='{type(command)}' is not of expected type 'str'")
elif command == "":
raise ValueError("Parameter 'command' is empty")
elif not isinstance(path, str) and path is not None:
- raise TypeError(f"path[]='{type(path)}' has not expected type 'str'")
+ raise TypeError(f"path[]='{type(path)}' is not of expected type 'str'")
elif path == "":
raise ValueError("Parameter 'path' is empty")
elif path is not None and not path.startswith("/"):
raise ValueError(f"path='{path}' does not start with / but should")
elif not isinstance(software, str) and software is not None:
- raise TypeError(f"software[]='{type(software)}' has not expected type 'str'")
+ raise TypeError(f"software[]='{type(software)}' is not of expected type 'str'")
elif software == "":
raise ValueError("Parameter 'software' is empty")
elif origin is not None and not validators.domain(origin.split("/")[0], rfc_2782=True):
domain_helper.raise_on(domain)
if not isinstance(column, str):
- raise TypeError(f"Parameter column[]='{type(column)}' has not expected type 'str'")
+ raise TypeError(f"Parameter column[]='{type(column)}' is not of expected type 'str'")
elif not column.startswith("last_"):
raise ValueError(f"Parameter column='{column}' is not expected")
elif blacklist.is_blacklisted(domain):
logger.debug("char='%s',domain='%s',blocked_hash='%s' - CALLED!", char, domain, blocked_hash)
if not isinstance(char, str):
- raise TypeError(f"Parameter char[]='{type(char)}' has not expected type 'str'")
+ raise TypeError(f"Parameter char[]='{type(char)}' is not of expected type 'str'")
elif char == "":
raise ValueError("Parameter 'char' is an empty string")
elif not isinstance(domain, str):
elif not char in domain:
raise ValueError(f"char='{char}' not found in domain='{domain}' but function invoked")
elif not isinstance(blocked_hash, str) and blocked_hash is not None:
- raise TypeError(f"Parameter blocked_hash[]='{type(blocked_hash)}' has not expected type 'str'")
+ raise TypeError(f"Parameter blocked_hash[]='{type(blocked_hash)}' is not of expected type 'str'")
# Init variables
row = None
domain_helper.raise_on(domain)
if not isinstance(response_time, float):
- raise TypeError(f"response_time[]='{type(response_time)}' has not expected type 'float'")
+ raise TypeError(f"response_time[]='{type(response_time)}' is not of expected type 'float'")
elif response_time < 0:
raise ValueError(f"response_time={response_time} is below zero")
domain_helper.raise_on(domain)
if not isinstance(offset, int):
- raise TypeError(f"offset[]='{type(offset)}' has not expected type 'float'")
+ raise TypeError(f"offset[]='{type(offset)}' is not of expected type 'float'")
elif offset < 0:
raise ValueError(f"offset={offset} is below zero")
domain_helper.raise_on(domain)
if not isinstance(path, str):
- raise TypeError(f"path[]='{type(path)}' has not expected type 'str'")
+ raise TypeError(f"path[]='{type(path)}' is not of expected type 'str'")
elif path == "":
raise ValueError(f"path='{path}' is an empty string")
elif not path.startswith("/"):
domain_helper.raise_on(domain)
if not isinstance(peers, list):
- raise TypeError(f"Parameter peers[]='{type(peers)}' has not expected type 'list'")
+ raise TypeError(f"Parameter peers[]='{type(peers)}' is not of expected type 'list'")
# Set timestamp
_set_pending_data("total_peers", domain, len(peers))
domain_helper.raise_on(domain)
if not isinstance(blocks, list):
- raise TypeError(f"Parameter blocks[]='{type(blocks)}' has not expected type 'list'")
+ raise TypeError(f"Parameter blocks[]='{type(blocks)}' is not of expected type 'list'")
# Set timestamp
_set_pending_data("total_blocks", domain, len(blocks))
domain_helper.raise_on(domain)
if not isinstance(obfuscated, int):
- raise TypeError(f"Parameter obfuscated[]='{type(obfuscated)}' has not expected type 'int'")
+ raise TypeError(f"Parameter obfuscated[]='{type(obfuscated)}' is not of expected type 'int'")
elif obfuscated < 0:
raise ValueError(f"Parameter obfuscated={obfuscated} is not valid")
domain_helper.raise_on(domain)
if not isinstance(url, str) and url is not None:
- raise TypeError(f"Parameter url[]='{type(url)}' has not expected type 'str'")
+ raise TypeError(f"Parameter url[]='{type(url)}' is not of expected type 'str'")
elif url == "":
raise ValueError("Parameter 'url' is an empty string")
elif url is not None and not validators.url(url):
domain_helper.raise_on(domain)
if not isinstance(mode, str) and mode is not None:
- raise TypeError(f"Parameter mode[]='{type(mode)}' has not expected type 'str'")
+ raise TypeError(f"Parameter mode[]='{type(mode)}' is not of expected type 'str'")
elif mode == "":
raise ValueError("Parameter 'mode' is an empty string")
domain_helper.raise_on(domain)
if not isinstance(has_obfuscation, bool):
- raise TypeError(f"Parameter has_obfuscation[]='{type(has_obfuscation)}' has not expected type 'bool'")
+ raise TypeError(f"Parameter has_obfuscation[]='{type(has_obfuscation)}' is not of expected type 'bool'")
# Set timestamp
_set_pending_data("has_obfuscation", domain, has_obfuscation)
domain_helper.raise_on(domain)
if not isinstance(software, str) and software is not None:
- raise TypeError(f"Parameter software[]='{type(software)}' has not expected type 'str'")
+ raise TypeError(f"Parameter software[]='{type(software)}' is not of expected type 'str'")
elif software == "":
raise ValueError("Parameter 'software' is an empty string")
domain_helper.raise_on(domain)
if not isinstance(software, str) and software is not None:
- raise TypeError(f"Parameter software[]='{type(software)}' has not expected type 'str'")
+ raise TypeError(f"Parameter software[]='{type(software)}' is not of expected type 'str'")
elif software == "":
raise ValueError("Parameter 'software' is an empty string")
logger.debug("value='%s',column='%s' - CALLED!", value, column)
if not isinstance(value, str):
- raise TypeError(f"Parameter value[]='{type(value)}' has not expected type 'str'")
+ raise TypeError(f"Parameter value[]='{type(value)}' is not of expected type 'str'")
elif value == "":
raise ValueError("Parameter 'value' is an empty string")
elif not isinstance(column, str):
- raise TypeError(f"Parameter column[]='{type(column)}' has not expected type 'str'")
+ raise TypeError(f"Parameter column[]='{type(column)}' is not of expected type 'str'")
elif column == "":
raise ValueError("Parameter 'column' is an empty string")
logger.debug("search='%s, column='%s'' - CALLED!", search, column)
if not isinstance(column, str):
- raise TypeError(f"Parameter column[]='{type(column)}' has not expected type 'str'")
+ raise TypeError(f"Parameter column[]='{type(column)}' is not of expected type 'str'")
elif column == "":
raise ValueError("Parameter 'column' is an empty string")
elif column in ["domain", "origin"]:
logger.debug("rows[]='%s',column='%s' - CALLED!", type(rows), column)
if not isinstance(rows, list):
- raise TypeError("rows[]='{type(rows)}' has not expected type 'list'")
+ raise TypeError("rows[]='{type(rows)}' is not of expected type 'list'")
elif len(rows) == 0:
raise ValueError("Parameter 'rows' is an empty list")
elif not isinstance(column, str):
- raise TypeError(f"column='{type(column)}' has not expected type 'str'")
+ raise TypeError(f"column='{type(column)}' is not of expected type 'str'")
elif column == "":
raise ValueError("Parameter 'column' is an empty string")
elif column not in ["domain", "origin"]:
logger.debug("pattern='%s' - CALLED!", pattern)
if not isinstance(pattern, str):
- raise TypeError(f"pattern[]='{type(pattern)}' has not expected type 'str'")
+ raise TypeError(f"pattern[]='{type(pattern)}' is not of expected type 'str'")
elif pattern == "":
raise ValueError("Parametern 'pattern' is an empty string")
logger.debug("pattern='%s' - CALLED!", pattern)
if not isinstance(pattern, str):
- raise TypeError(f"pattern[]='{type(pattern)}' has not expected type 'str'")
+ raise TypeError(f"pattern[]='{type(pattern)}' is not of expected type 'str'")
elif pattern == "":
raise ValueError("Parametern 'pattern' is an empty string")
elif has(pattern):
logger.debug("pattern='%s' - CALLED!", pattern)
if not isinstance(pattern, str):
- raise TypeError(f"pattern[]='{type(pattern)}' has not expected type 'str'")
+ raise TypeError(f"pattern[]='{type(pattern)}' is not of expected type 'str'")
elif pattern == "":
raise ValueError("Parametern 'pattern' is an empty string")
elif not has(pattern):
logger.debug("pattern='%s' - CALLED!", pattern)
if not isinstance(pattern, str):
- raise TypeError(f"pattern[]='{type(pattern)}' has not expected type 'str'")
+ raise TypeError(f"pattern[]='{type(pattern)}' is not of expected type 'str'")
elif pattern == "":
raise ValueError("Parametern 'pattern' is an empty string")
elif not has(pattern):
logger.debug("doc[]='%s',only='%s' - CALLED!", type(doc), only)
if not isinstance(doc, bs4.BeautifulSoup):
- raise TypeError(f"Parameter doc[]='{type(only)}' has not expected type 'bs4.BeautifulSoup'")
+ raise TypeError(f"Parameter doc[]='{type(only)}' is not of expected type 'bs4.BeautifulSoup'")
elif not isinstance(only, str) and only is not None:
- raise TypeError(f"Parameter only[]='{type(only)}' has not expected type 'str'")
+ raise TypeError(f"Parameter only[]='{type(only)}' is not of expected type 'str'")
elif isinstance(only, str) and only == "":
raise ValueError("Parameter 'only' is an empty string")
logger.warning("row()=%d does not contain key 'host': row='%s',domain='%s' - SKIPPED!", len(row), row, domain)
continue
elif not isinstance(row["host"], str):
- logger.warning("row[host][]='%s' has not expected type 'str' - SKIPPED!", type(row["host"]))
+ logger.warning("row[host][]='%s' is not of expected type 'str' - SKIPPED!", type(row["host"]))
continue
elif row["host"] == "":
logger.warning("row[host] is an empty string,domain='%s' - SKIPPED!", domain)
logger.warning("instance(%d)='%s' has no key 'host' - SKIPPED!", len(instance), instance)
continue
elif not isinstance(instance["host"], str):
- logger.warning("instance[host][]='%s' has not expected type 'str' - SKIPPED!", type(instance["host"]))
+ logger.warning("instance[host][]='%s' is not of expected type 'str' - SKIPPED!", type(instance["host"]))
continue
elif instance["host"] == "":
logger.warning("instance[host] is an empty string,domain='%s' - SKIPPED!", domain)
logger.debug("tags[%s]()=%d,search='%s' - CALLED!", type(tags), len(tags), search)
if not isinstance(tags, bs4.element.ResultSet):
- raise TypeError(f"Parameter tags[]='{type(tags)}' has not expected type 'ResultSet'")
+ raise TypeError(f"Parameter tags[]='{type(tags)}' is not of expected type 'ResultSet'")
elif not isinstance(search, str):
- raise TypeError(f"Parameter search[]='{type(search)}' has not expected type 'str'")
+ raise TypeError(f"Parameter search[]='{type(search)}' is not of expected type 'str'")
elif search == "":
raise ValueError("Parameter 'search' is an empty string")
logger.debug("EXIT!")
-def deobfuscate(domain: str, blocker: str, domain_hash: str = None) -> str:
- logger.debug("domain='%s',blocker='%s',domain_hash='%s' - CALLED!", domain, blocker, domain_hash)
+def deobfuscate(pattern: str, blocker: str, domain_hash: str = None) -> str:
+ logger.debug("pattern='%s',blocker='%s',domain_hash='%s' - CALLED!", pattern, blocker, domain_hash)
domain_helper.raise_on(blocker)
- if validators.domain(domain, rfc_2782=True) and blacklist.is_blacklisted(domain):
- raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
+ if validators.domain(pattern, rfc_2782=True) and blacklist.is_blacklisted(pattern):
+ raise RuntimeError(f"pattern='{pattern}' is blacklisted but function was invoked")
elif not isinstance(domain_hash, str) and domain_hash is not None:
- raise TypeError(f"Parameter domain_hash[]='{type(domain_hash)}' has not expected type 'str'")
+ raise TypeError(f"Parameter domain_hash[]='{type(domain_hash)}' is not of expected type 'str'")
elif domain_hash == "":
raise ValueError("Parameter 'domain_hash' is an empty string")
- logger.debug("Checking domain='%s' ...", domain)
- if domain.find("*") >= 0:
+ # Init domain with current value (which might be a pattern)
+ domain = pattern
+
+ logger.debug("Checking pattern='%s' ...", pattern)
+ if pattern.find("*") >= 0:
logger.debug("blocker='%s' uses obfuscated domains", blocker)
instances.set_has_obfuscation(blocker, True)
# Obscured domain name with no hash
- row = instances.deobfuscate("*", domain, domain_hash)
+ row = instances.deobfuscate("*", pattern, domain_hash)
logger.debug("row[]='%s'", type(row))
if row is not None:
- logger.debug("domain='%s' de-obscured to '%s'", domain, row["domain"])
+ logger.debug("pattern='%s' de-obscured to '%s'", pattern, row["domain"])
domain = row["domain"]
else:
- logger.warning("blocker='%s' has domain='%s' that cannot be deobfuscated.", blocker, domain)
- elif domain.find("?") >= 0:
+ logger.warning("blocker='%s' has pattern='%s' that cannot be deobfuscated.", blocker, pattern)
+ elif pattern.find("?") >= 0:
logger.debug("blocker='%s' uses obfuscated domains", blocker)
instances.set_has_obfuscation(blocker, True)
# Obscured domain name with no hash
- row = instances.deobfuscate("?", domain, domain_hash)
+ row = instances.deobfuscate("?", pattern, domain_hash)
logger.debug("row[]='%s'", type(row))
if row is not None:
- logger.debug("domain='%s' de-obscured to '%s'", domain, row["domain"])
+ logger.debug("pattern='%s' de-obscured to '%s'", pattern, row["domain"])
domain = row["domain"]
else:
- logger.warning("blocker='%s' has domain='%s' that cannot be deobfuscated.", blocker, domain)
+ logger.warning("blocker='%s' has pattern='%s' that cannot be deobfuscated.", blocker, pattern)
else:
- logger.debug("domain='%s' is not obfuscated", domain)
+ logger.warning("pattern='%s' is not supported, returning possibly obfuscated domain ...", pattern)
logger.debug("domain='%s' - EXIT!", domain)
return domain