(config.get("connection_timeout"), config.get("read_timeout"))
)
- logger.debug("JSON API returned %d elements", len(fetched))
+ logger.debug("fetched(%d)[]='%s'", len(fetched), type(fetched))
if "error_message" in fetched:
logger.warning("API returned error_message='%s' - EXIT!", fetched["error_message"])
return 101
headers=headers,
timeout=(config.get("connection_timeout"), config.get("read_timeout"))
)
- logger.debug("fetched[]='%s'", type(fetched))
+ logger.debug("fetched(%d)[]='%s'", len(fetched), type(fetched))
if "error_message" in fetched:
logger.warning("Error during fetching API result: '%s' - EXIT!", fetched["error_message"])
{},
(config.get("connection_timeout"), config.get("read_timeout"))
)
- logger.debug("fetched[]='%s'", type(fetched))
+ logger.debug("fetched(%d)[]='%s'", len(fetched), type(fetched))
if "error_message" in fetched:
logger.warning("Error during fetching API result: '%s' - EXIT!", fetched["error_message"])
import requests
import validators
+from fba.helpers import blacklist
from fba.helpers import config
from fba.helpers import cookies
from fba.helpers import domain as domain_helper
logger.debug("domain='%s',origin='%s',software='%s',command='%s',path='%s',_DEPTH=%d - CALLED!", domain, origin, software, command, path, _DEPTH)
domain_helper.raise_on(domain)
- if not isinstance(origin, str) and origin is not None:
+ if blacklist.is_blacklisted(domain):
+ raise Exception(f"domain='{domain}' is blacklisted but function was invoked")
+ elif not isinstance(origin, str) and origin is not None:
raise ValueError(f"Parameter origin[]='{type(origin)}' is not of type 'str'")
elif not isinstance(command, str):
raise ValueError(f"Parameter command[]='{type(command)}' is not of type 'str'")
logger.debug("domain='%s',software='%s',origin='%s' - CALLED!", domain, software, origin)
domain_helper.raise_on(domain)
- if not isinstance(software, str) and software is not None:
+ if blacklist.is_blacklisted(domain):
+ raise Exception(f"domain='{domain}' is blacklisted but function was invoked")
+ elif not isinstance(software, str) and software is not None:
raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'")
elif isinstance(software, str) and software == "":
raise ValueError("Parameter 'software' is empty")
timeout=(config.get("connection_timeout"), config.get("read_timeout"))
)
- logger.debug("data[]='%s'", type(data))
+ logger.debug("data(%d)[]='%s'", len(data), type(data))
if "error_message" in data:
logger.debug("Was not able to fetch peers from path='%s',domain='%s' ...", path, domain)
instances.set_last_error(domain, data)
logger.debug("domain='%s',path='%s' - CALLED!", domain, path)
domain_helper.raise_on(domain)
- if not isinstance(path, str):
+ if blacklist.is_blacklisted(domain):
+ raise Exception(f"domain='{domain}' is blacklisted but function was invoked")
+ elif not isinstance(path, str):
raise ValueError(f"path[]='{type(path)}' is not of type 'str'")
elif path == "":
raise ValueError("Parameter 'path' is empty")
+ elif not path.startswith("/"):
+ raise ValueError("path='{path}' does not start with / but should")
software = None
logger.debug("domain='%s',path='%s' - CALLED!", domain, path)
domain_helper.raise_on(domain)
- if not isinstance(path, str) and path is not None:
+ if blacklist.is_blacklisted(domain):
+ raise Exception(f"domain='{domain}' is blacklisted but function was invoked")
+ elif not isinstance(path, str) and path is not None:
raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'")
logger.debug("Fetching nodeinfo from domain='%s',path='%s' ...", domain, path)
if not instances.is_registered(domain):
raise Exception(f"domain='{domain}' is not registered but function is invoked.")
+ elif blacklist.is_blacklisted(domain):
+ raise Exception(f"domain='{domain}' is blacklisted but function was invoked")
# Init block list
blocklist = list()
)
rows = list()
- logger.debug("data[]='%s'", type(data))
+ logger.debug("data(%d)[]='%s'", len(data), type(data))
if "error_message" in data:
logger.debug("Was not able to fetch domain_blocks from domain='%s': status_code=%d,error_message='%s'", domain, data['status_code'], data['error_message'])
instances.set_last_error(domain, data)
logger.debug("Marking domain='%s' as successfully handled ...", domain)
instances.set_success(domain)
- logger.debug("rows[%s]()=%d", type(rows), len(rows))
+ logger.debug("rows(%d)[]='%s'", len(rows), type(rows))
if len(rows) > 0:
logger.debug("Checking %d entries from domain='%s' ...", len(rows), domain)
for block in rows:
reason = tidyup.reason(block["comment"]) if "comment" in block and block["comment"] is not None and block["comment"] != "" else None
- logger.debug("Appending blocker='%s',blocked='%s',reason='%s',block_level='%s'", domain, block["domain"], reason, block["severity"])
+ logger.debug("Appending blocker='%s',blocked='%s',reason='%s',block_level='%s' ...", domain, block["domain"], reason, block["severity"])
blocklist.append({
"blocker" : domain,
"blocked" : block["domain"],
raise ValueError(f"path[]='{type(path)}' is not of type 'str'")
elif path == "":
raise ValueError("Parameter 'path' is empty")
+ elif not path.startswith("/"):
+ raise ValueError("path='{path}' does not start with / but should")
elif not isinstance(data, str):
raise ValueError(f"data[]='{type(data)}' is not of type 'str'")
elif not isinstance(headers, dict):
raise ValueError(f"path[]='{type(path)}' is not of type 'str'")
elif path == "":
raise ValueError("Parameter 'path' is empty")
+ elif not path.startswith("/"):
+ raise ValueError("path='{path}' does not start with / but should")
elif not isinstance(headers, dict):
raise ValueError(f"headers[]='{type(headers)}' is not of type 'list'")
elif not isinstance(timeout, tuple):
if response.ok and response.status_code == 200:
logger.debug("Parsing JSON response from domain='%s',path='%s' ...", domain, path)
json_reply["json"] = json_helper.from_response(response)
+ logger.debug("json_reply[json][]='%s'", type(json_reply["json"]))
logger.debug("response.ok='%s',response.status_code=%d,response.text()=%d", response.ok, response.status_code, len(response.text))
if not response.ok or response.status_code > 200 or len(response.text) == 0:
raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'")
elif path == "":
raise ValueError("Parameter 'path' is empty")
+ elif not path.startswith("/"):
+ raise ValueError("path='{path}' does not start with / but should")
elif not isinstance(headers, dict):
raise ValueError(f"headers[]='{type(headers)}' is not of type 'dict'")
elif not isinstance(timeout, tuple):
start = 0
try:
- logger.debug("Sending GET request to '%s%s' ...", domain, path)
+ logger.debug("Sending GET request to 'https://%s%s' ...", domain, path)
start = time.perf_counter()
response = reqto.get(
f"https://{domain}{path}",
from urllib.parse import urlparse
+from fba.helpers import blacklist
from fba.helpers import config
from fba.helpers import domain as domain_helper
logger.debug("domain='%s',path='%s',update_mode='%s' - CALLED!", domain, path, update_mode)
domain_helper.raise_on(domain)
- if not isinstance(path, str) and path is not None:
+ if blacklist.is_blacklisted(domain):
+ raise Exception(f"domain='{domain}' is blacklisted but function was invoked")
+ elif not isinstance(path, str) and path is not None:
raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'")
elif not isinstance(update_mode, bool) and update_mode is not None:
raise ValueError(f"Parameter update_mode[]='{type(update_mode)}' is not of type 'bool'")
timeout=(config.get("nodeinfo_connection_timeout"), config.get("nodeinfo_read_timeout"))
)
- logger.debug("data[]='%s'", type(data))
+ logger.debug("data(%d)[]='%s'", len(data), type(data))
if "error_message" not in data and "json" in data:
logger.debug("Updating last_nodeinfo for domain='%s' ....", domain)
instances.set_last_nodeinfo(domain)
logger.debug("domain='%s' - CALLED!", domain)
domain_helper.raise_on(domain)
+ if blacklist.is_blacklisted(domain):
+ raise Exception(f"domain='{domain}' is blacklisted but function was invoked")
+
# No CSRF by default, you don't have to add network.api_headers by yourself here
headers = tuple()
headers,
(config.get("nodeinfo_connection_timeout"), config.get("nodeinfo_read_timeout"))
)
- logger.debug("data[]='%s'", type(data))
+ logger.debug("data(%d)[]='%s'", len(data), type(data))
if "error_message" not in data and "json" in data and len(data["json"]) > 0:
logger.debug("path='%s' returned valid json()=%d - BREAK!", path, len(data["json"]))
break
raise ValueError(f"path[]='{type(path)}' is not of type 'str'")
elif path == "":
raise ValueError("Parameter 'path' is empty")
+ elif not path.startswith("/"):
+ raise ValueError("path='{path}' does not start with / but should")
elif not isinstance(software, str) and software is not None:
raise ValueError(f"software[]='{type(software)}' is not of type 'str'")
elif software == "":