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:
|
try:
|
||||||
conn = await asyncpg.connect(DB_DSN)
|
conn = await asyncpg.connect(DB_DSN)
|
||||||
await conn.execute("""
|
await conn.execute("""
|
||||||
INSERT INTO packets(
|
INSERT INTO packet_log(
|
||||||
interface_ingress,
|
interface,
|
||||||
interfaces_egress,
|
direction,
|
||||||
src_mac, dst_mac, eth_type,
|
src_mac,
|
||||||
src_ip, dst_ip, ip_protocol,
|
dst_mac,
|
||||||
packet_len, raw_packet
|
eth_type,
|
||||||
)
|
src_ip,
|
||||||
VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)
|
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["ingress"], # interface where packet arrived
|
||||||
pkt_info["egress"],
|
"unknown", # direction (can update later)
|
||||||
pkt_info["src_mac"],
|
pkt_info["src_mac"],
|
||||||
pkt_info["dst_mac"],
|
pkt_info["dst_mac"],
|
||||||
pkt_info["eth_type"],
|
pkt_info["eth_type"],
|
||||||
@@ -86,6 +91,7 @@ async def db_insert_packet(pkt_info: dict):
|
|||||||
pkt_info["dst_ip"],
|
pkt_info["dst_ip"],
|
||||||
pkt_info["protocol"],
|
pkt_info["protocol"],
|
||||||
pkt_info["length"],
|
pkt_info["length"],
|
||||||
|
str(pkt_info.get("egress")), # optional egress info as text
|
||||||
pkt_info["raw"]
|
pkt_info["raw"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user