test clear package api
Some checks failed
Build and Deploy MITM Webserver / build (push) Has been cancelled

This commit is contained in:
2026-03-01 17:57:24 +01:00
parent bd37cdf628
commit 613c8b8c5a
2 changed files with 48 additions and 0 deletions

View File

@@ -142,3 +142,28 @@ async def websocket_packets(ws: WebSocket):
except Exception:
pass
logger.debug("WebSocket connection closed and cleaned up for client %s", ws.client)
@router.delete("/packets")
async def clear_packets(reset_id: bool = Query(True)):
"""
Clear all packet logs from the database.
Uses TRUNCATE internally for high performance.
"""
db = shared.db
if db is None:
raise HTTPException(status_code=503, detail="Database not available")
success = await db.clear_all_packets(reset_identity=reset_id)
if not success:
raise HTTPException(status_code=500, detail="Failed to clear packet table")
logger.info("User initiated clear_packets (reset_id=%s)", reset_id)
return JSONResponse(
content={
"status": "success",
"message": "All packets have been cleared",
"reset_id": reset_id
}
)