"ngrok.io",
]
+pending_errors = {
+}
+
nodeinfos = [
"http://nodeinfo.diaspora.software/ns/schema/2.1",
"http://nodeinfo.diaspora.software/ns/schema/2.0",
domain
])
- except:
- print("ERROR: failed SQL query:", domain)
+ if cursor.rowcount == 0:
+ print("WARNING: Did not update any rows:", domain)
+
+ except BaseException as e:
+ print("ERROR: failed SQL query:", domain, e)
sys.exit(255)
def update_last_error(domain: str, res: any):
# NOISY-DEBUG: print("DEBUG: domain,res.status_code:", domain, res.status_code, res.reason)
try:
- cursor.execute("UPDATE instances SET last_status_code = ?, last_error_details = ?, last_updated = ? WHERE domain = ?", [
- res.status_code,
- res.reason,
- time.time(),
- domain
- ])
+ if type(res) is str:
+ cursor.execute("UPDATE instances SET last_status_code = 999, last_error_details = ?, last_updated = ? WHERE domain = ?", [
+ res,
+ time.time(),
+ domain
+ ])
+ else:
+ cursor.execute("UPDATE instances SET last_status_code = ?, last_error_details = ?, last_updated = ? WHERE domain = ?", [
+ res.status_code,
+ res.reason,
+ time.time(),
+ domain
+ ])
- except:
- print("ERROR: failed SQL query:", domain)
+ if cursor.rowcount == 0:
+ # NOISY-DEBUG: print("DEBUG: Did not update any rows:", domain)
+ pending_errors[domain] = res
+
+ except BaseException as e:
+ print("ERROR: failed SQL query:", domain, e)
sys.exit(255)
def update_last_nodeinfo(domain: str):
domain
])
- except:
- print("ERROR: failed SQL query:", domain)
+ if cursor.rowcount == 0:
+ print("WARNING: Did not update any rows:", domain)
+
+ except BaseException as e:
+ print("ERROR: failed SQL query:", domain, e)
sys.exit(255)
connection.commit()
json = res.json()
break
elif not res.ok or res.status_code >= 400:
- # NOISY-DEBUG: print("DEBUG: Failed fetching nodeinfo from domain:", domain)
+ print("WARNING: Failed fetching nodeinfo from domain:", domain)
update_last_error(domain, res)
continue
# NOISY-DEBUG: print("DEBUG: json[]:", type(json))
if json is None or len(json) == 0:
print("WARNING: Failed fetching nodeinfo from domain:", domain)
+ update_last_error(domain, "Cannot fetch nodeinfo")
# NOISY-DEBUG: print("DEBUG: Returning json[]:", type(json))
return json
except:
print("WARNING: Failed fetching .well-known info:", domain)
+ update_last_error(domain, "Cannot fetch .well-known")
pass
# NOISY-DEBUG: print("DEBUG: Returning json[]:", type(json))
),
)
+ if cursor.rowcount == 0:
+ print("WARNING: Did not update any rows:", domain)
+
except:
print("ERROR: failed SQL query:", reason, blocker, blocked, block_level)
sys.exit(255)
)
)
+ if cursor.rowcount == 0:
+ print("WARNING: Did not update any rows:", domain)
+
except:
print("ERROR: failed SQL query:", last_seen, blocker, blocked, block_level)
sys.exit(255)
),
)
- except:
- print("ERROR: failed SQL query:", domain)
+ if domain in pending_errors:
+ print("DEBUG: domain has pending error be updated:", domain)
+ update_last_error(domain, pending_errors[domain])
+ del pending_errors[domain]
+
+ except BaseException as e:
+ print("ERROR: failed SQL query:", domain, e)
sys.exit(255)
else:
# NOISY-DEBUG: print("DEBUG: Updating nodeinfo for domain:", domain)
}
translations = {
- "Silenced instances": "Silenced servers",
- "Suspended instances": "Suspended servers",
- "Gesperrte Server": "Suspended servers",
- "Gefilterte Medien": "Filtered media",
- "Stummgeschaltete Server": "Silenced servers",
- "停止済みのサーバー": "Suspended servers",
+ "Silenced instances" : "Silenced servers",
+ "Suspended instances" : "Suspended servers",
+ "Gesperrte Server" : "Suspended servers",
+ "Gefilterte Medien" : "Filtered media",
+ "Stummgeschaltete Server" : "Silenced servers",
+ "停止済みのサーバー" : "Suspended servers",
"メディアを拒否しているサーバー": "Filtered media",
- "サイレンス済みのサーバー": "Silenced servers",
- "שרתים מושעים": "Suspended servers",
- "מדיה מסוננת": "Filtered media",
- "שרתים מוגבלים": "Silenced servers",
- "Serveurs suspendus": "Suspended servers",
- "Médias filtrés": "Filtered media",
- "Serveurs limités": "Silenced servers",
+ "サイレンス済みのサーバー" : "Silenced servers",
+ "שרתים מושעים" : "Suspended servers",
+ "מדיה מסוננת" : "Filtered media",
+ "שרתים מוגבלים" : "Silenced servers",
+ "Serveurs suspendus" : "Suspended servers",
+ "Médias filtrés" : "Filtered media",
+ "Serveurs limités" : "Silenced servers",
}
try:
# NOISY-DEBUG: print("DEBUG: Fetching misskey blocks from domain:", domain)
blocks = {
"suspended": [],
- "blocked": []
+ "blocked" : []
}
try:
import fba
def fetch_instances(domain: str, origin: str):
- # NOISY-DEBUG: print("DEBUG: Fetching instances for domain:", domain, origin)
- peerlist = fba.get_peers(domain)
-
- if (peerlist is None):
- print("ERROR: Cannot fetch peers:", domain)
- return
-
+ # NOISY-DEBUG: print("DEBUG: domain,origin:", domain, origin)
fba.cursor.execute(
"SELECT domain FROM instances WHERE domain = ? LIMIT 1", [domain]
)
# NOISY-DEBUG: print("DEBUG: Adding new domain:", domain, origin)
fba.add_instance(domain, origin, sys.argv[0])
+ # NOISY-DEBUG: print("DEBUG: Fetching instances for domain:", domain, origin)
+ peerlist = fba.get_peers(domain)
+
+ if (peerlist is None):
+ print("ERROR: Cannot fetch peers:", domain)
+ return
+
print(f"INFO: Checking {len(peerlist)} instances from {domain} ...")
for instance in peerlist:
instance = instance.lower()
"SELECT domain FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'gotosocial', 'bookwyrm', 'takahe') AND (last_nodeinfo IS NULL OR last_nodeinfo < ?) ORDER BY rowid DESC", [time.time() - fba.config["recheck_instance"]]
)
-for instance in fba.cursor.fetchall():
- if fba.is_blacklisted(instance[0]):
- # NOISY-DEBUG: print("DEBUG: domain is blacklisted:", instance)
+for row in fba.cursor.fetchall():
+ domain = row[0]
+ # NOISY-DEBUG: print("DEBUG: domain:", domain)
+ if fba.is_blacklisted(domain):
+ # NOISY-DEBUG: print("DEBUG: domain is blacklisted:", domain)
continue
- print("INFO: Fetching instances for instance:", instance[0])
- fetch_instances(instance[0], None)
+ print("INFO: Fetching instances for instance:", domain)
+ fetch_instances(domain, None)
fba.connection.close()