test websocket data enrichment
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 1m40s

This commit is contained in:
2026-03-01 17:44:09 +01:00
parent a1dbbcb8d5
commit bd37cdf628

View File

@@ -77,7 +77,7 @@ class DatabasePool:
try: try:
async with self._pool.acquire() as conn: async with self._pool.acquire() as conn:
await conn.execute( new_row = await conn.fetchrow(
""" """
INSERT INTO packets( INSERT INTO packets(
iface, iface,
@@ -93,6 +93,7 @@ class DatabasePool:
length, length,
raw raw
) VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12) ) VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12)
RETURNING id, timestamp
""", """,
pkt_info["iface"], pkt_info["iface"],
pkt_info.get("src_mac"), pkt_info.get("src_mac"),
@@ -110,6 +111,11 @@ class DatabasePool:
except Exception: except Exception:
logger.exception("DB insert failed") logger.exception("DB insert failed")
return return
# Update the dictionary with the DB-generated values
if new_row:
pkt_info["id"] = new_row["id"]
# Convert timestamp to ISO string for JSON serialization in WebSockets
pkt_info["timestamp"] = new_row["timestamp"].isoformat()
# notify broadcaster (non-blocking). broadcaster is expected to be thread-safe. # notify broadcaster (non-blocking). broadcaster is expected to be thread-safe.
if self.broadcaster: if self.broadcaster: