fix: update database insertion query to log additional packet details and correct table name
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 7s
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 7s
This commit is contained in:
@@ -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"]
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user