test websocket data enrichment
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 1m40s
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 1m40s
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user