From 2ee99b4fd8f5f86f174fce582da229ab028121c3 Mon Sep 17 00:00:00 2001 From: malmert Date: Tue, 25 Nov 2025 16:40:25 +0100 Subject: [PATCH] fix: update database insertion query to log additional packet details and correct table name --- backend/src/network_sniffer.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/backend/src/network_sniffer.py b/backend/src/network_sniffer.py index b8cabe4..be7aaa7 100644 --- a/backend/src/network_sniffer.py +++ b/backend/src/network_sniffer.py @@ -68,17 +68,22 @@ async def db_insert_packet(pkt_info: dict): try: conn = await asyncpg.connect(DB_DSN) await conn.execute(""" - INSERT INTO packets( - interface_ingress, - interfaces_egress, - src_mac, dst_mac, eth_type, - src_ip, dst_ip, ip_protocol, - packet_len, raw_packet - ) - VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10) + INSERT INTO packet_log( + interface, + direction, + src_mac, + dst_mac, + eth_type, + src_ip, + dst_ip, + ip_protocol, + packet_len, + nft_verdict, + raw_packet + ) VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11) """, - pkt_info["ingress"], - pkt_info["egress"], + pkt_info["ingress"], # interface where packet arrived + "unknown", # direction (can update later) pkt_info["src_mac"], pkt_info["dst_mac"], pkt_info["eth_type"], @@ -86,6 +91,7 @@ async def db_insert_packet(pkt_info: dict): pkt_info["dst_ip"], pkt_info["protocol"], pkt_info["length"], + str(pkt_info.get("egress")), # optional egress info as text pkt_info["raw"] )