test clear package api
Some checks failed
Build and Deploy MITM Webserver / build (push) Has been cancelled
Some checks failed
Build and Deploy MITM Webserver / build (push) Has been cancelled
This commit is contained in:
@@ -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
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user