"slogan" : "### Your footer slogan ###",
"recheck_instance" : 604800,
"recheck_block" : 43200,
+ "recheck_nodeinfo" : 604800,
"misskey_limit" : 100,
"error_log_cleanup" : 604800,
"write_error_log" : "true",
# No CSRF by default, you don't have to add network.api_headers by yourself here
headers = tuple()
+ domain = "pixelfed.org"
try:
- logger.debug("Checking CSRF from pixelfed.org")
- headers = csrf.determine("pixelfed.org", dict())
+ logger.debug("Checking CSRF from domain='%s' ...", domain)
+ headers = csrf.determine(domain, dict())
except network.exceptions as exception:
logger.warning("Exception '%s' during checking CSRF (fetch_peers,%s) - EXIT!", type(exception), __name__)
return list()
try:
logger.debug("Fetching JSON from pixelfed.org API, headers()=%d ...", len(headers))
fetched = network.get_json_api(
- "pixelfed.org",
+ domain,
"/api/v1/servers/all.json?scope=All&country=all&language=all",
headers,
(config.get("connection_timeout"), config.get("read_timeout"))
database.cursor.execute("SELECT domain, software FROM instances WHERE software = ?", [args.software])
else:
logger.info("Fetching domains for recently updated ...")
- database.cursor.execute("SELECT domain, software FROM instances WHERE last_nodeinfo < ? OR last_nodeinfo IS NULL AND software IS NULL AND last_status_code < 999", [time.time() - config.get("recheck_block")])
+ database.cursor.execute("SELECT domain, software FROM instances WHERE last_nodeinfo < ? OR last_nodeinfo IS NULL", [time.time() - config.get("recheck_nodeinfo")])
domains = database.cursor.fetchall()
import bs4
import reqto
+import requests
from fba.helpers import config
from fba.helpers import cookies
reqheaders["X-CSRF-Token"] = tag["content"]
elif domain != components.netloc:
logger.warning("domain='%s' doesn't match components.netloc='%s', maybe redirect to other domain?", domain, components.netloc)
- instances.set_last_error(domain, f"Redirect from domain='{domain}' to components.netloc='{components.netloc}'")
+ message = f"Redirect from domain='{domain}' to components.netloc='{components.netloc}'"
+ instances.set_last_error(domain, message)
+ raise requests.exceptions.TooManyRedirects(message)
logger.debug("reqheaders()=%d - EXIT!", len(reqheaders))
return reqheaders
except network.exceptions as exception:
logger.warning("Exception '%s' during checking CSRF (nodeinfo,%s) - EXIT!", type(exception), __name__)
instances.set_last_error(domain, exception)
+ instances.set_software(domain, None)
+ instances.set_detection_mode(domain, None)
+ instances.set_nodeinfo_url(domain, None)
return {
"status_code" : 500,
"error_message": f"exception[{type(exception)}]='{str(exception)}'",
instances.set_detection_mode(domain, "SITE_NAME")
elif domain != components.netloc:
logger.warning("domain='%s' doesn't match components.netloc='%s', maybe redirect to other domain?", domain, components.netloc)
- instances.set_last_error(domain, f"Redirect from domain='{domain}' to components.netloc='{components.netloc}'")
+ message = f"Redirect from domain='{domain}' to components.netloc='{components.netloc}'"
+ instances.set_last_error(domain, message)
+ instances.set_software(domain, None)
+ instances.set_detection_mode(domain, None)
+ instances.set_nodeinfo_url(domain, None)
+ raise requests.exceptions.TooManyRedirects(message)
logger.debug("software[]='%s'", type(software))
if isinstance(software, str) and software == "":