added first version of single ip page breakdiwn
This commit is contained in:
committed by
Lorenzo Venerandi
parent
75722051d6
commit
f7416518fe
@@ -888,7 +888,9 @@ class DatabaseManager:
|
|||||||
logs = query.offset(offset).limit(page_size).all()
|
logs = query.offset(offset).limit(page_size).all()
|
||||||
# Get total count of attackers
|
# Get total count of attackers
|
||||||
total_access_logs = (
|
total_access_logs = (
|
||||||
session.query(AccessLog).filter(AccessLog.ip == sanitize_ip(ip_filter)).count()
|
session.query(AccessLog)
|
||||||
|
.filter(AccessLog.ip == sanitize_ip(ip_filter))
|
||||||
|
.count()
|
||||||
)
|
)
|
||||||
total_pages = (total_access_logs + page_size - 1) // page_size
|
total_pages = (total_access_logs + page_size - 1) // page_size
|
||||||
|
|
||||||
@@ -905,7 +907,8 @@ class DatabaseManager:
|
|||||||
"timestamp": log.timestamp.isoformat(),
|
"timestamp": log.timestamp.isoformat(),
|
||||||
"attack_types": [d.attack_type for d in log.attack_detections],
|
"attack_types": [d.attack_type for d in log.attack_detections],
|
||||||
}
|
}
|
||||||
for log in logs ],
|
for log in logs
|
||||||
|
],
|
||||||
"pagination": {
|
"pagination": {
|
||||||
"page": page,
|
"page": page,
|
||||||
"page_size": page_size,
|
"page_size": page_size,
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ async def dashboard_page(request: Request):
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/ip/{ip_address:path}")
|
@router.get("/ip/{ip_address:path}")
|
||||||
async def ip_page(ip_address: str, request: Request):
|
async def ip_page(ip_address: str, request: Request):
|
||||||
db = get_db()
|
db = get_db()
|
||||||
@@ -57,7 +58,7 @@ async def ip_page(ip_address: str, request: Request):
|
|||||||
"request": request,
|
"request": request,
|
||||||
"dashboard_path": dashboard_path,
|
"dashboard_path": dashboard_path,
|
||||||
"stats": stats,
|
"stats": stats,
|
||||||
"ip_address": ip_address
|
"ip_address": ip_address,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -67,4 +68,3 @@ async def ip_page(ip_address: str, request: Request):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
get_app_logger().error(f"Error fetching IP stats: {e}")
|
get_app_logger().error(f"Error fetching IP stats: {e}")
|
||||||
return JSONResponse(content={"error": str(e)})
|
return JSONResponse(content={"error": str(e)})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user