print("ERROR: failed SQL query:", blocker, blocked, reason, block_level, first_added, last_seen)
sys.exit(255)
-def add_instance(domain: str):
- # NOISY-DEBUG: print("DEBUG: domain:", domain)
+def add_instance(domain: str, origin: str):
+ # NOISY-DEBUG: print("DEBUG: domain,origin:", domain, origin)
if domain.find("@") > 0:
print("WARNING: Bad domain name:", domain)
raise
+ elif origin is not None and origin.find("@") > 0:
+ print("WARNING: Bad origin name:", origin)
+ raise
- print("--- Adding new instance:", domain)
+ print("--- Adding new instance:", domain, origin)
try:
c.execute(
- "INSERT INTO instances (domain,hash,software) VALUES (?, ?, ?)",
+ "INSERT INTO instances (domain,origin,hash,software) VALUES (?, ?, ?, ?)",
(
domain,
+ origin,
get_hash(domain),
determine_software(domain)
),
)
if fba.c.fetchone() == None:
- # NOISY-DEBUG: print("DEBUG: Domain wasn't found, adding:", blocked)
- fba.add_instance(blocked)
+ # NOISY-DEBUG: print("DEBUG: Domain wasn't found, adding:", blocked, blocker)
+ fba.add_instance(blocked, blocker)
timestamp = int(time.time())
fba.c.execute(
)
if fba.c.fetchone() == None:
- # NOISY-DEBUG: print("DEBUG: Hash wasn't found, adding:", blocked)
- fba.add_instance(blocked)
+ # NOISY-DEBUG: print("DEBUG: Hash wasn't found, adding:", blocked, blocker)
+ fba.add_instance(blocked, blocker)
else:
# Doing the hash search for instance names as well to tidy up DB
fba.c.execute(
)
if fba.c.fetchone() == None:
- # NOISY-DEBUG: print("DEBUG: Hash wasn't found, adding:", blocked)
- fba.add_instance(blocked)
+ # NOISY-DEBUG: print("DEBUG: Hash wasn't found, adding:", blocked, blocker)
+ fba.add_instance(blocked, blocker)
timestamp = int(time.time())
fba.c.execute(
)
if fba.c.fetchone() == None:
- # NOISY-DEBUG: print("DEBUG: Hash wasn't found, adding:", blocked)
- fba.add_instance(blocked)
+ # NOISY-DEBUG: print("DEBUG: Updating block reason:", blocker, blocked, reason)
+ fba.update_block_reason(reason, blocker, blocked, block_level)
fba.c.execute(
"SELECT * FROM blocks WHERE blocker = ? AND blocked = ? AND block_level = ?",
import time
import fba
-def fetch_instances(domain: str):
- # NOISY-DEBUG: print("DEBUG: Fetching instances for domain:", domain)
+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):
)
if fba.c.fetchone() == None:
- # NOISY-DEBUG: print("DEBUG: Adding new domain:", domain)
- fba.add_instance(domain)
+ # NOISY-DEBUG: print("DEBUG: Adding new domain:", domain, origin)
+ fba.add_instance(domain, origin)
fba.conn.commit()
return
)
if fba.c.fetchone() == None:
- # NOISY-DEBUG: print("DEBUG: Adding new instance:", instance)
- fba.add_instance(instance)
+ # NOISY-DEBUG: print("DEBUG: Adding new instance:", instance, domain)
+ fba.add_instance(instance, domain)
fba.conn.commit()
instance = sys.argv[1]
# Initial fetch
-fetch_instances(instance)
+fetch_instances(instance, None)
# Loop through some instances
fba.c.execute(
continue
print("INFO: Fetching instances for instance:", instance[0])
- fetch_instances(instance[0])
+ fetch_instances(instance[0], None)
fba.conn.close()