from fba import cache
from fba import fba
from fba import federation
+from fba import network
# Found info from node, such as nodeinfo URL, detection mode that needs to be
# written to database. Both arrays must be filled at the same time or else
elif domain.find("/profile/") > 0 or domain.find("/users/") > 0:
raise Exception(f"domain='{domain}' is a single user")
- # DEBUG: print("DEBUG: domain,origin,command,path:", domain, origin, command, path)
- software = federation.determine_software(domain, path)
+ software = None
+ try:
+ # DEBUG: print("DEBUG: domain,origin,command,path:", domain, origin, command, path)
+ software = federation.determine_software(domain, path)
+ except network.exceptions as exception:
+ print(f"WARNING Exception '{type(exception)}' during determining software type")
# DEBUG: print("DEBUG: Determined software:", software)
if software == "lemmy" and domain.find("/c/") > 0:
# Blocks
blockdict = list()
- rows = federation.fetch_nodeinfo(domain, nodeinfo_url)
+ rows = None
+ try:
+ rows = federation.fetch_nodeinfo(domain, nodeinfo_url)
+ except network.exceptions as exception:
+ print(f"WARNING: Exception '{type(exception)}' during fetching nodeinfo")
if rows is None:
print("WARNING: Could not fetch nodeinfo from domain:", domain)
# DEBUG: print("DEBUG: Looking up instance by domain:", blocked)
if not instances.is_registered(blocked):
+ # Commit changes
+ fba.connection.commit()
+
# DEBUG: print(f"DEBUG: Domain blocked='{blocked}' wasn't found, adding ..., domain='{domain}',origin='{origin}',nodeinfo_url='{nodeinfo_url}'")
instances.add(blocked, domain, inspect.currentframe().f_code.co_name, nodeinfo_url)
print(f"WARNING: blocked='{blocked}' is a reversed .arpa domain and should not be used generally.")
continue
elif not instances.is_registered(blocked):
- # DEBUG: print(f"DEBUG: Domain blocked='{blocked}' wasn't found, adding ..., domain='{domain}',origin='{origin}',nodeinfo_url='{nodeinfo_url}'")
+ # DEBUG: print(f"DEBUG: Domain blocked='{blocked}' wasn't found, adding ..., domain='{domain}',origin='{origin}',nodein
instances.add(blocked, domain, inspect.currentframe().f_code.co_name, nodeinfo_url)
# DEBUG: print(f"DEBUG: Updating block reason: reason='{reason}',domain='{domain}',blocked='{blocked}',block_level='{block_level}'")