From 05747f5ef74dd43bb2ce096b8522d5d5194ea9b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 20 May 2023 15:07:40 +0200 Subject: [PATCH] Continued: - added origin to track which instance has referenced this one --- blocks_empty.db | Bin 28672 -> 28672 bytes fba.py | 12 ++++++++---- fetch_blocks.py | 16 ++++++++-------- fetch_instances.py | 16 ++++++++-------- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/blocks_empty.db b/blocks_empty.db index dc11b3532ecb5e55ac3b2fa97761b1c6d8cbd73e..14ad7e8cb364df4f54a3ac78d54ca1805389dbfb 100644 GIT binary patch delta 127 zcmZp8z}WDBae}nqa|Q+mb|_{9(y|kEj3u8l=y^}%<=0_g<%wqCYvz5&6V2PrYs^!= zSy12x_v8Q`Zmz~qE_QKwdB$pQT9<#iPDi!#$Q^Atin{USqLBSI7$-9lW06jJhY Z6EpKPHyiW*VPw2AvGKwp1%X8h0RWcCBAfsK delta 105 zcmZp8z}WDBae}nqGX@3*b|_{9(lQfuj3u8j=y^}%<=0_g 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) ), diff --git a/fetch_blocks.py b/fetch_blocks.py index 2a13023..cc2b0ec 100644 --- a/fetch_blocks.py +++ b/fetch_blocks.py @@ -75,8 +75,8 @@ for blocker, software in fba.c.fetchall(): ) 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( @@ -228,8 +228,8 @@ for blocker, software in fba.c.fetchall(): ) 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( @@ -319,8 +319,8 @@ for blocker, software in fba.c.fetchall(): ) 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( @@ -382,8 +382,8 @@ for blocker, software in fba.c.fetchall(): ) 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 = ?", diff --git a/fetch_instances.py b/fetch_instances.py index cc855e6..9237fc1 100644 --- a/fetch_instances.py +++ b/fetch_instances.py @@ -4,8 +4,8 @@ import json 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): @@ -16,8 +16,8 @@ def fetch_instances(domain: str): ) 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 @@ -44,8 +44,8 @@ def fetch_instances(domain: str): ) 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() @@ -56,7 +56,7 @@ def fetch_instances(domain: str): instance = sys.argv[1] # Initial fetch -fetch_instances(instance) +fetch_instances(instance, None) # Loop through some instances fba.c.execute( @@ -74,6 +74,6 @@ for instance in fba.c.fetchall(): continue print("INFO: Fetching instances for instance:", instance[0]) - fetch_instances(instance[0]) + fetch_instances(instance[0], None) fba.conn.close() -- 2.39.5