]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 20 May 2023 13:07:40 +0000 (15:07 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 20 May 2023 13:09:20 +0000 (15:09 +0200)
- added origin to track which instance has referenced this one

blocks_empty.db
fba.py
fetch_blocks.py
fetch_instances.py

index dc11b3532ecb5e55ac3b2fa97761b1c6d8cbd73e..14ad7e8cb364df4f54a3ac78d54ca1805389dbfb 100644 (file)
Binary files a/blocks_empty.db and b/blocks_empty.db differ
diff --git a/fba.py b/fba.py
index 78f6b8bf80b0af52c2763aedcf5c36bf5bf1b93a..8c708e9f510f9466ab292b429bc98a4e4f214f83 100644 (file)
--- a/fba.py
+++ b/fba.py
@@ -233,18 +233,22 @@ def block_instance(blocker: str, blocked: str, reason: str, block_level: str, fi
         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)
             ),
index 2a1302344495fae99bc501fcb4d8cd4a1f6f6ee5..cc2b0ec2543434550138cc155a924898837bff34 100644 (file)
@@ -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 = ?",
index cc855e636bc1174b54cf0676f22e0080350c0308..9237fc1566aa6cec63c70db8de0449b7a4698be5 100644 (file)
@@ -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()