"Content-Type": "application/json",
}
-# URL for fetching peers
-get_peers_url = "/api/v1/instance/peers"
-
# Connect to database
connection = sqlite3.connect("blocks.db")
cursor = connection.cursor()
instances.add(domain, origin, script, path)
# DEBUG: print("DEBUG: Fetching instances for domain:", domain, software)
- peerlist = get_peers(domain, software)
+ peerlist = fetch_peers(domain, software)
if (peerlist is None):
print("ERROR: Cannot fetch peers:", domain)
# DEBUG: print("DEBUG: EXIT!")
-def get_peers(domain: str, software: str) -> list:
+def fetch_peers(domain: str, software: str) -> list:
# DEBUG: print(f"DEBUG: domain({len(domain)})={domain},software={software} - CALLED!")
if type(domain) != str:
raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
raise ValueError(f"software[]={type(software)} is not 'str'")
if software == "misskey":
- # DEBUG: print(f"DEBUG: Invoking misskey.get_peers({domain}) ...")
- return misskey.get_peers(domain)
+ # DEBUG: print(f"DEBUG: Invoking misskey.fetch_peers({domain}) ...")
+ return misskey.fetch_peers(domain)
elif software == "lemmy":
- # DEBUG: print(f"DEBUG: Invoking lemmy.get_peers({domain}) ...")
- return lemmy.get_peers(domain)
+ # DEBUG: print(f"DEBUG: Invoking lemmy.fetch_peers({domain}) ...")
+ return lemmy.fetch_peers(domain)
elif software == "peertube":
- # DEBUG: print(f"DEBUG: Invoking peertube.get_peers({domain}) ...")
- return peertube.get_peers(domain)
+ # DEBUG: print(f"DEBUG: Invoking peertube.fetch_peers({domain}) ...")
+ return peertube.fetch_peers(domain)
- # DEBUG: print(f"DEBUG: Fetching get_peers_url='{get_peers_url}' from '{domain}',software='{software}' ...")
+ # DEBUG: print(f"DEBUG: Fetching peers from '{domain}',software='{software}' ...")
peers = list()
try:
- response = get_response(domain, get_peers_url, api_headers, (config.get("connection_timeout"), config.get("read_timeout")))
+ response = get_response(domain, "/api/v1/instance/peers", api_headers, (config.get("connection_timeout"), config.get("read_timeout")))
data = json_from_response(response)
# DEBUG: print(f"DEBUG: response.ok={response.ok},response.status_code={response.status_code},data[]='{type(data)}'")
if not response.ok or response.status_code >= 400:
- # DEBUG: print(f"DEBUG: Was not able to fetch '{get_peers_url}', trying alternative ...")
+ # DEBUG: print(f"DEBUG: Was not able to fetch peers, trying alternative ...")
response = get_response(domain, "/api/v3/site", api_headers, (config.get("connection_timeout"), config.get("read_timeout")))
data = json_from_response(response)