# NOISY-DEBUG: print("DEBUG: json[]:", type(json))
if json is None or len(json) == 0:
print("WARNING: Failed fetching nodeinfo from domain:", domain)
+ json = fetch_wellknown_nodeinfo(domain)
+
+ # NOISY-DEBUG: print("DEBUG: Returning json[]:", type(json))
+ return json
+
+def fetch_wellknown_nodeinfo(domain: str) -> list:
+ # NOISY-DEBUG: print("DEBUG: Fetching .well-known info for domain:", domain)
+ json = {}
+
+ try:
+ res = reqto.get(f"https://{domain}/.well-known/nodeinfo", headers=headers, timeout=(config["connection_timeout"], config["read_timeout"]))
+ # NOISY-DEBUG: print("DEBUG: domain,res.ok:", domain, res.ok)
+ if res.ok and res.json() is not None:
+ nodeinfo = res.json()
+ # NOISY-DEBUG: print("DEBUG: Found entries:", len(nodeinfo), domain)
+ if "links" in nodeinfo:
+ # NOISY-DEBUG: print("DEBUG: Found links in nodeinfo():", len(nodeinfo["links"]))
+ for link in nodeinfo["links"]:
+ # NOISY-DEBUG: print("DEBUG: rel,href:", link["rel"], link["href"])
+ if link["rel"] == "http://nodeinfo.diaspora.software/ns/schema/2.0":
+ # NOISY-DEBUG: print("DEBUG: Fetching nodeinfo from:", link["href"])
+ res = reqto.get(link["href"])
+ # NOISY-DEBUG: print("DEBUG: href,res.ok:", link["href"], res.ok)
+ if res.ok and res.json() is not None:
+ # NOISY-DEBUG: print("DEBUG: Found JSON nodeinfo():", len(res.json()))
+ json = res.json()
+ break
+
+ except:
+ print("WARNING: Failed fetching .well-known info:", domain)
+ pass
# NOISY-DEBUG: print("DEBUG: Returning json[]:", type(json))
return json
elif blocked.count("*") < 1:
# No obsfucation for this instance
fba.cursor.execute(
- "SELECT hash FROM instances WHERE domain = ? LIMIT 1", [blocked]
+ "SELECT hash FROM instances WHERE domain = ?", [blocked]
)
if fba.cursor.fetchone() == None:
if blocked == "":
print("WARNING: blocked is empty:", blocker)
continue
- if blocked.count("*") > 0:
+ elif blocked.count("*") > 0:
# GTS does not have hashes for obscured domains, so we have to guess it
fba.cursor.execute(
"SELECT domain FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", [blocked.replace("*", "_")]
except Exception as e:
print("error:", e, blocker, software)
else:
- print("WARNING: Unknown software:", software)
+ print("WARNING: Unknown software:", blocker, software)
if fba.config["bot_enabled"] and len(blockdict) > 0:
send_bot_post(blocker, blockdict)