elif blocked != None:
if blocked > 500:
raise HTTPException(status_code=400, detail="Too many results")
- fba.c.execute("SELECT blocked, COUNT(blocked) FROM blocks WHERE block_level = 'reject' group by blocked ORDER BY COUNT(blocked) DESC LIMIT ?", (blocked,))
+ fba.c.execute("SELECT blocked, COUNT(blocked) FROM blocks WHERE block_level = 'reject' group by blocked ORDER BY COUNT(blocked) DESC LIMIT ?", [blocked])
elif blockers != None:
if blockers > 500:
raise HTTPException(status_code=400, detail="Too many results")
- fba.c.execute("SELECT blocker, COUNT(blocker) FROM blocks WHERE block_level = 'reject' group by blocker ORDER BY COUNT(blocker) DESC LIMIT ?", (blockers,))
+ fba.c.execute("SELECT blocker, COUNT(blocker) FROM blocks WHERE block_level = 'reject' group by blocker ORDER BY COUNT(blocker) DESC LIMIT ?", [blockers])
scores = fba.c.fetchall()
scoreboard = []
fba.c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks WHERE blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? OR blocked = ? ORDER BY first_added ASC",
(domain, "*." + domain, wildchar, fba.get_hash(domain), punycode, "*." + punycode))
elif reverse != None:
- fba.c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks WHERE blocker = ? ORDER BY first_added ASC", (reverse,))
+ fba.c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks WHERE blocker = ? ORDER BY first_added ASC", [reverse])
else:
- fba.c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks WHERE reason like ? AND reason != '' ORDER BY first_added ASC", ("%"+reason+"%",))
+ fba.c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks WHERE reason like ? AND reason != '' ORDER BY first_added ASC", ["%" + reason + "%"])
blocks = fba.c.fetchall()
result = {}
if blocked.count("*") > 1:
# -ACK!-oma also started obscuring domains without hash
fba.c.execute(
- "SELECT domain FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", (blocked.replace("*", "_"),)
+ "SELECT domain FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", [blocked.replace("*", "_")]
)
searchres = fba.c.fetchone()
# NOISY-DEBUG: print("DEBUG: searchres[]:", type(searchres))
# NOISY-DEBUG: print("DEBUG: Looking up instance by domain:", blocked)
fba.c.execute(
- "SELECT domain FROM instances WHERE domain = ?", (blocked,)
+ "SELECT domain FROM instances WHERE domain = ?", [blocked]
)
if fba.c.fetchone() == None:
elif blocked.count("*") > 1:
# same domain guess as above, but for reasons field
fba.c.execute(
- "SELECT domain FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", (blocked.replace("*", "_"),)
+ "SELECT domain FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", [blocked.replace("*", "_")]
)
searchres = fba.c.fetchone()
elif blocked.count("*") < 1:
# No obsfucation for this instance
fba.c.execute(
- "SELECT hash FROM instances WHERE domain = ? LIMIT 1", (blocked,)
+ "SELECT hash FROM instances WHERE domain = ? LIMIT 1", [blocked]
)
if fba.c.fetchone() == None:
else:
# Doing the hash search for instance names as well to tidy up DB
fba.c.execute(
- "SELECT domain FROM instances WHERE hash = ? LIMIT 1", (blocked_hash,)
+ "SELECT domain FROM instances WHERE hash = ? LIMIT 1", [blocked_hash]
)
searchres = fba.c.fetchone()
if blocked.count("*") > 0:
# Some friendica servers also obscure domains without hash
fba.c.execute(
- "SELECT domain FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", (blocked.replace("*", "_"),)
+ "SELECT domain FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", [blocked.replace("*", "_")]
)
searchres = fba.c.fetchone()
if searchres != None:
if blocked.count("?") > 0:
# Some obscure them with question marks, not sure if that's dependent on version or not
fba.c.execute(
- "SELECT domain FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", (blocked.replace("?", "_"),)
+ "SELECT domain FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", [blocked.replace("?", "_")]
)
searchres = fba.c.fetchone()
if searchres != None:
# NOISY-DEBUG: print("DEBUG: AFTER-blocked:", blocked)
fba.c.execute(
- "SELECT domain FROM instances WHERE domain = ?", (blocked,)
+ "SELECT domain FROM instances WHERE domain = ?", [blocked]
)
if fba.c.fetchone() == None:
if blocked.count("*") > 0:
# GTS does not have hashes for obscured domains, so we have to guess it
fba.c.execute(
- "SELECT domain FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", (blocked.replace("*", "_"),)
+ "SELECT domain FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", [blocked.replace("*", "_")]
)
searchres = fba.c.fetchone()
blocked = searchres[0]
fba.c.execute(
- "SELECT domain FROM instances WHERE domain = ?", (blocked,)
+ "SELECT domain FROM instances WHERE domain = ?", [blocked]
)
if fba.c.fetchone() == None:
import fba
def fetch_instances(domain: str):
- print("DEBUG: Fetching instances for domain:", domain)
+ # NOISY-DEBUG: print("DEBUG: Fetching instances for domain:", domain)
peerlist = fba.get_peers(domain)
if (peerlist is None):
print("ERROR: Cannot fetch peers:", domain)
fba.c.execute(
- "SELECT domain FROM instances WHERE domain = ? LIMIT 1", (domain,)
+ "SELECT domain FROM instances WHERE domain = ? LIMIT 1", [domain]
)
if fba.c.fetchone() == None:
# NOISY-DEBUG: print("DEBUG: Handling instance:", instance)
try:
fba.c.execute(
- "SELECT domain FROM instances WHERE domain = ? LIMIT 1", (instance,)
+ "SELECT domain FROM instances WHERE domain = ? LIMIT 1", [instance]
)
if fba.c.fetchone() == None:
# NOISY-DEBUG: print("DEBUG: domain is blacklisted:", instance)
continue
- print("DEBUG: Fetching instances for instance:", instance[0])
+ print("INFO: Fetching instances for instance:", instance[0])
fetch_instances(instance[0])
fba.conn.close()