if (peerlist is None):
print("ERROR: Cannot fetch peers:", domain)
+ return
- fba.c.execute(
- "SELECT domain FROM instances WHERE domain = ? LIMIT 1", [domain]
- )
-
- if fba.c.fetchone() == None:
- # NOISY-DEBUG: print("DEBUG: Adding new domain:", domain, origin)
- fba.add_instance(domain, origin)
+ fba.cursor.execute(
+ "SELECT domain FROM instances WHERE domain = ? LIMIT 1", [domain]
+ )
- fba.conn.commit()
- return
+ if fba.cursor.fetchone() == None:
+ # NOISY-DEBUG: print("DEBUG: Adding new domain:", domain, origin)
+ fba.add_instance(domain, origin, sys.argv[0])
+ print(f"INFO: Checking {len(peerlist)} instances from {domain} ...")
for instance in peerlist:
instance = instance.lower()
+
if instance.find("@") > 0:
print("WARNING: Bad instance name,domain:", instance, domain)
continue
- blacklisted = False
- for peer in fba.blacklist:
- if peer in instance:
- blacklisted = True
-
- if blacklisted:
- # NOISY-DEBUG: print("DEBUG: domain is blacklisted:", domain)
+ if fba.is_blacklisted(instance):
+ # NOISY-DEBUG: print("DEBUG: instance is blacklisted:", instance)
continue
# NOISY-DEBUG: print("DEBUG: Handling instance:", instance)
try:
- fba.c.execute(
+ fba.cursor.execute(
"SELECT domain FROM instances WHERE domain = ? LIMIT 1", [instance]
)
- if fba.c.fetchone() == None:
+ if fba.cursor.fetchone() == None:
# NOISY-DEBUG: print("DEBUG: Adding new instance:", instance, domain)
- fba.add_instance(instance, domain)
+ fba.add_instance(instance, domain, sys.argv[0])
- fba.conn.commit()
+ fba.connection.commit()
except Exception as e:
print("ERROR:", e, instance)
fetch_instances(instance, None)
# Loop through some instances
-fba.c.execute(
+fba.cursor.execute(
"SELECT domain FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'gotosocial') AND (last_nodeinfo IS NULL OR last_nodeinfo < ?) ORDER BY rowid DESC", [time.time() - fba.config["recheck_instance"]]
)
-for instance in fba.c.fetchall():
- blacklisted = False
- for domain in fba.blacklist:
- if domain in instance[0]:
- blacklisted = True
-
- if blacklisted:
+for instance in fba.cursor.fetchall():
+ if fba.is_blacklisted(instance[0]):
# NOISY-DEBUG: print("DEBUG: domain is blacklisted:", instance)
continue
print("INFO: Fetching instances for instance:", instance[0])
fetch_instances(instance[0], None)
-fba.conn.close()
+fba.connection.close()