# NOISY-DEBUG: print("DEBUG: Updating last_blocked for domain", domain)
try:
- c.execute("UPDATE instances SET last_blocked = ? WHERE domain = ?", [
+ c.execute("UPDATE instances SET last_blocked = ?, last_updated = ? WHERE domain = ?", [
+ time.time(),
time.time(),
domain
])
# NOISY-DEBUG: print("DEBUG: domain,res.status_code", domain, res.status_code)
try:
- c.execute("UPDATE instances SET last_status_code = ? WHERE domain = ?", [
+ c.execute("UPDATE instances SET last_status_code = ?, last_updated = ? WHERE domain = ?", [
res.status_code,
+ time.time(),
domain
])
# NOISY-DEBUG: print("DEBUG: Updating last_nodeinfo for domain:", domain)
try:
- c.execute("UPDATE instances SET last_nodeinfo = ? WHERE domain = ?", [
+ c.execute("UPDATE instances SET last_nodeinfo = ?, last_updated = ? WHERE domain = ?", [
+ time.time(),
time.time(),
domain
])
# NOISY: print("--- Updating block reason:", reason, blocker, blocked, block_level)
try:
c.execute(
- "UPDATE blocks SET reason = ? WHERE blocker = ? AND blocked = ? AND block_level = ? AND reason = ''",
+ "UPDATE blocks SET reason = ?, last_seen = ? WHERE blocker = ? AND blocked = ? AND block_level = ? AND reason = ''",
(
reason,
+ time.time(),
blocker,
blocked,
block_level
print("ERROR: failed SQL query:", reason, blocker, blocked, block_level)
sys.exit(255)
-def update_last_seen(last_seen: int, blocker: str, blocked: str, block_level: str):
- # NOISY: print("--- Updating last_seen:", last_seen, blocker, blocked, block_level)
+def update_last_seen(blocker: str, blocked: str, block_level: str):
+ # NOISY: print("--- Updating last_seen for:", blocker, blocked, block_level)
try:
c.execute(
"UPDATE blocks SET last_seen = ? WHERE blocker = ? AND blocked = ? AND block_level = ?",
(
- last_seen,
+ time.time(),
blocker,
blocked,
block_level
print("ERROR: failed SQL query:", last_seen, blocker, blocked, block_level)
sys.exit(255)
-def block_instance(blocker: str, blocked: str, reason: str, block_level: str, first_added: int, last_seen: int):
- # NOISY-DEBUG: print("DEBUG: blocker,blocked,reason,block_level,first_added,last_seen:", blocker, blocked, reason, block_level, first_added, last_seen)
+def block_instance(blocker: str, blocked: str, reason: str, block_level: str):
+ # NOISY-DEBUG: print("DEBUG: blocker,blocked,reason,block_level:", blocker, blocked, reason, block_level)
if blocker.find("@") > 0:
print("WARNING: Bad blocker:", blocker)
raise
blocked,
reason,
block_level,
- first_added,
- last_seen
+ time.time(),
+ time.time()
),
)
print(f"--- Adding new instance {domain} (origin: {origin})")
try:
c.execute(
- "INSERT INTO instances (domain,origin,originator,hash,software) VALUES (?, ?, ?, ?, ?)",
+ "INSERT INTO instances (domain, origin, originator, hash, software, first_seen) VALUES (?, ?, ?, ?, ?, ?)",
(
domain,
origin,
originator,
get_hash(domain),
- determine_software(domain)
+ determine_software(domain),
+ time.time()
),
)
# NOISY-DEBUG: print("DEBUG: Domain wasn't found, adding:", blocked, blocker)
fba.add_instance(blocked, blocker, argv[0])
- timestamp = int(time.time())
fba.c.execute(
"SELECT * FROM blocks WHERE blocker = ? AND blocked = ? AND block_level = ?",
(
if fba.c.fetchone() == None:
# NOISY-DEBUG: print("DEBUG: Blocking:", blocker, blocked, block_level)
- fba.block_instance(blocker, blocked, "unknown", block_level, timestamp, timestamp)
+ fba.block_instance(blocker, blocked, "unknown", block_level)
if block_level == "reject":
# NOISY-DEBUG: print("DEBUG: Adding to blockdict:", blocked)
})
else:
# NOISY-DEBUG: print("DEBUG: Updating last_seen:", blocker, blocked, block_level)
- fba.update_last_seen(timestamp, blocker, blocked, block_level)
+ fba.update_last_seen(blocker, blocked, block_level)
fba.conn.commit()
# NOISY-DEBUG: print("DEBUG: Updating domain: ", searchres[0])
blocked = searchres[0]
- timestamp = int(time.time())
fba.c.execute(
"SELECT * FROM blocks WHERE blocker = ? AND blocked = ? AND block_level = ?",
(
)
if fba.c.fetchone() == None:
- fba.block_instance(blocker, blocked if blocked.count("*") <= 1 else blocked_hash, reason, block_level, timestamp, timestamp)
+ fba.block_instance(blocker, blocked if blocked.count("*") <= 1 else blocked_hash, reason, block_level)
if block_level == "reject":
blockdict.append(
"reason": reason
})
else:
- fba.update_last_seen(timestamp, blocker, blocked if blocked.count("*") <= 1 else blocked_hash, block_level)
+ fba.update_last_seen(blocker, blocked if blocked.count("*") <= 1 else blocked_hash, block_level)
if reason != '':
# NOISY-DEBUG: print("DEBUG: Updating block reason:", blocker, blocked, reason)
# NOISY-DEBUG: print("DEBUG: Hash wasn't found, adding:", blocked, blocker)
fba.add_instance(blocked, blocker)
- timestamp = int(time.time())
fba.c.execute(
"SELECT * FROM blocks WHERE blocker = ? AND blocked = ?",
(blocker, blocked),
)
if fba.c.fetchone() == None:
- fba.block_instance(blocker, blocked, reason, block_level, timestamp, timestamp)
+ fba.block_instance(blocker, blocked, reason, block_level)
if block_level == "reject":
blockdict.append(
"reason": reason
})
else:
- fba.update_last_seen(timestamp, blocker, blocked, block_level)
+ fba.update_last_seen(blocker, blocked, block_level)
if reason != '':
# NOISY-DEBUG: print("DEBUG: Updating block reason:", blocker, blocked, reason)
"reject"
),
)
- timestamp = int(time.time())
if fba.c.fetchone() == None:
- fba.block_instance(blocker, blocked, "unknown", "reject", timestamp, timestamp)
+ fba.block_instance(blocker, blocked, "unknown", "reject")
blockdict.append(
{
"reason": None
})
else:
- fba.update_last_seen(timestamp, blocker, blocked, "reject")
+ fba.update_last_seen(blocker, blocked, "reject")
if "public_comment" in peer:
reason = peer["public_comment"]