elif domain.endswith(".arpa"):
print(f"WARNING: domain='{domain}' is a reversed .arpa domain and should not be used generally.")
return
- elif not instances.is_registered(domain):
+ elif not validators.domain(domain):
+ raise ValueError(f"domain='{domain}' is not a valid domain")
+ elif not instances.is_registered(domain.split("/")[0]):
# DEBUG: print("DEBUG: Adding new domain:", domain, origin)
instances.add(domain, origin, command, path)
if instance.endswith(".arpa"):
print(f"WARNING: instance='{instance}' is a reversed .arpa domain and should not be used generally.")
continue
+ elif instance.find("/profile/") > 0 or instance.find("/users/") > 0:
+ print(f"DEBUG: instance='{instance}' is a link to a single user profile - SKIPPED!")
+ continue
elif not instances.is_registered(instance):
# DEBUG: print("DEBUG: Adding new instance:", instance, domain)
instances.add(instance, domain, command)
# DEBUG: print("DEBUG: EXIT!")
-def add(domain: str, origin: str, command: str, path: str = None):
- # DEBUG: print(f"DEBUG: domain='{domain}',origin='{origin}',command='{command}',path='{path}' - CALLED!")
+def add(domain: str, origin: str, command: str, path: str = None, software: str = None):
+ # DEBUG: print(f"DEBUG: domain='{domain}',origin='{origin}',command='{command}',path='{path}',software='{software}' - CALLED!")
if not isinstance(domain, str):
raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
elif domain == "":
raise ValueError("Parameter 'command' is empty")
elif not validators.domain(domain.split("/")[0]):
raise ValueError(f"Bad domain name='{domain}'")
+ elif not isinstance(path, str) and path is not None:
+ raise ValueError(f"path[]='{type(path)}' is not 'str'")
+ elif path == "":
+ raise ValueError("Parameter 'path' is empty")
+ elif not isinstance(software, str) and software is not None:
+ raise ValueError(f"software[]='{type(software)}' is not 'str'")
+ elif software == "":
+ raise ValueError("Parameter 'software' is empty")
elif domain.endswith(".arpa"):
raise ValueError(f"Please don't crawl .arpa domains: domain='{domain}'")
elif origin is not None and not validators.domain(origin.split("/")[0]):
raise ValueError(f"Bad origin name='{origin}'")
elif blacklist.is_blacklisted(domain):
raise Exception(f"domain='{domain}' is blacklisted, but method invoked")
- elif domain.find("/profile/") > 0 or domain.find("/users/") > 0:
+ elif domain.find("/profile/") > 0 or domain.find("/users/") > 0 or (software == "lemmy" and domain.find("/c/") > 0):
raise Exception(f"domain='{domain}' is a single user")
- 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")
+ if isinstance(software, str):
+ 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: