# Init peers variable
peers = list()
+ # No CSRF by default, you don't have to add network.api_headers by yourself here
headers = tuple()
- # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
try:
- headers = csrf.determine(domain, dict())
+ # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
+ headers = csrf.determine(domain, dict())
except network.exceptions as exception:
- print(f"WARNING: Exception '{type(exception)}' during checking CSRF - EXIT!")
- return
+ print(f"WARNING: Exception '{type(exception)}' during checking CSRF (fetch_peers,{__name__}) - EXIT!")
+ return peers
# DEBUG: print(f"DEBUG: Fetching peers from '{domain}',software='{software}' ...")
data = network.get_json_api(
# DEBUG: print("DEBUG: Returning peers[]:", type(peers))
return peers
-def fetch_nodeinfo(domain: str, path: str = None) -> list:
+def fetch_nodeinfo(domain: str, path: str = None) -> dict:
# DEBUG: print(f"DEBUG: domain='{domain}',path={path} - CALLED!")
if not isinstance(domain, str):
raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
# DEBUG: print(f"DEBUG: Fetching nodeinfo from domain='{domain}' ...")
nodeinfo = fetch_wellknown_nodeinfo(domain)
- # DEBUG: print(f"DEBUG: nodeinfo({len(nodeinfo)})={nodeinfo}")
- if len(nodeinfo) > 0:
- # DEBUG: print("DEBUG: nodeinfo()={len(nodeinfo))} - EXIT!")
+ # DEBUG: print(f"DEBUG: nodeinfo[{type(nodeinfo)}]='{nodeinfo}'")
+ if "error_message" in nodeinfo:
+ print(f"WARNING: Error during fetching nodeinfo: '{nodeinfo['error_message']}' - EXIT!")
return nodeinfo
+ # No CSRF by default, you don't have to add network.api_headers by yourself here
headers = tuple()
- # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
try:
- headers = csrf.determine(domain, dict())
+ # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
+ headers = csrf.determine(domain, dict())
except network.exceptions as exception:
- print(f"WARNING: Exception '{type(exception)}' during checking CSRF - EXIT!")
- return
+ print(f"WARNING: Exception '{type(exception)}' during checking CSRF (nodeinfo,{__name__}) - EXIT!")
+ return dict()
request_paths = [
"/nodeinfo/2.1.json",
]
for request in request_paths:
+ # DEBUG: print(f"DEBUG: path[{type(path)}]='{path}',request='{request'}")
if path is not None and path != "" and path != request:
# DEBUG: print(f"DEBUG: path='{path}' does not match request='{request}' - SKIPPED!")
continue
# DEBUG: print(f"DEBUG: data()={len(data)} - EXIT!")
return data
-def fetch_wellknown_nodeinfo(domain: str) -> list:
+def fetch_wellknown_nodeinfo(domain: str) -> dict:
# DEBUG: print(f"DEBUG: domain='{domain}' - CALLED!")
if not isinstance(domain, str):
raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
elif domain == "":
raise ValueError("Parameter 'domain' is empty")
+ # No CSRF by default, you don't have to add network.api_headers by yourself here
headers = tuple()
- # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
try:
- headers = csrf.determine(domain, dict())
+ # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
+ headers = csrf.determine(domain, dict())
except network.exceptions as exception:
- print(f"WARNING: Exception '{type(exception)}' during checking CSRF - EXIT!")
- return
+ print(f"WARNING: Exception '{type(exception)}' during checking CSRF (fetch_wellknown,{__name__}) - EXIT!")
+ return {
+ "status_code" : 500,
+ "error_message": type(exception)
+ }
# DEBUG: print("DEBUG: Fetching .well-known info for domain:", domain)
data = network.get_json_api(
# DEBUG: print(f"DEBUG: Fetching nodeinfo from '{domain}' ...")
data = fetch_nodeinfo(domain, path)
- # DEBUG: print("DEBUG: data[]:", type(data))
+ # DEBUG: print(f"DEBUG: data[{type(data)}]='{data}'")
if "error_message" in data:
# DEBUG: print("DEBUG: Could not determine software type:", domain)
return fetch_generator_from_path(domain)
elif domain == "":
raise ValueError("Parameter 'domain' is empty")
+ peers = list()
+
+ # No CSRF by default, you don't have to add network.api_headers by yourself here
headers = tuple()
- # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
try:
- headers = csrf.determine(domain, dict())
+ # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
+ headers = csrf.determine(domain, dict())
except network.exceptions as exception:
- print(f"WARNING: Exception '{type(exception)}' during checking CSRF - EXIT!")
- return
+ print(f"WARNING: Exception '{type(exception)}' during checking CSRF (fetch_peers,{__name__}) - EXIT!")
+ return peers
- peers = list()
try:
# DEBUG: print(f"DEBUG: domain='{domain}' is Lemmy, fetching JSON ...")
data = network.get_json_api(
peers = list()
offset = 0
step = config.get("misskey_limit")
+
+ # No CSRF by default, you don't have to add network.api_headers by yourself here
headers = tuple()
- # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
try:
- headers = csrf.determine(domain, dict())
+ # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
+ headers = csrf.determine(domain, dict())
except network.exceptions as exception:
- print(f"WARNING: Exception '{type(exception)}' during checking CSRF - EXIT!")
- return
+ print(f"WARNING: Exception '{type(exception)}' during checking CSRF (fetch_peers,{__name__}) - EXIT!")
+ return peers
# iterating through all "suspended" (follow-only in its terminology)
# instances page-by-page, since that troonware doesn't support
offset = 0
step = config.get("misskey_limit")
+
+ # No CSRF by default, you don't have to add network.api_headers by yourself here
headers = tuple()
- # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
try:
- headers = csrf.determine(domain, dict())
+ # DEBUG: print(f"DEBUG: Checking CSRF for domain='{domain}'")
+ headers = csrf.determine(domain, dict())
except network.exceptions as exception:
- print(f"WARNING: Exception '{type(exception)}' during checking CSRF - EXIT!")
- return
+ print(f"WARNING: Exception '{type(exception)}' during checking CSRF (fetch_blocks,{__name__}) - EXIT!")
+ return blocklist
# iterating through all "suspended" (follow-only in its terminology)
# instances page-by-page since it doesn't support sending them all at once
print(f"DEBUG: domain='{domain}' is a PeerTube, fetching JSON ...")
peers = list()
start = 0
+
+ # No CSRF by default, you don't have to add network.api_headers by yourself here
headers = tuple()
- print(f"DEBUG: Checking CSRF for domain='{domain}'")
try:
- headers = csrf.determine(domain, dict())
+ print(f"DEBUG: Checking CSRF for domain='{domain}'")
+ headers = csrf.determine(domain, dict())
except network.exceptions as exception:
- print(f"WARNING: Exception '{type(exception)}' during checking CSRF - EXIT!")
- return
+ print(f"WARNING: Exception '{type(exception)}' during checking CSRF (fetch_peers,{__name__}) - EXIT!")
+ return peers
for mode in ["followers", "following"]:
print(f"DEBUG: domain='{domain}',mode='{mode}'")