Amnezia-style SSH server connect with verify, ping and server_info

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-25 21:30:43 +03:00
co-authored by Cursor
parent 088f02cdbe
commit 321a5b2504
9 changed files with 334 additions and 40 deletions
+20
View File
@@ -62,12 +62,14 @@ async def servers_page(request: Request, db: AsyncSession = Depends(get_db), adm
select(VpnServer).options(selectinload(VpnServer.clients)).order_by(VpnServer.id)
)
).scalars().all()
probes = await vpn_service.probe_servers(list(servers))
return request.app.state.templates.TemplateResponse(
"admin/servers.html",
{
"request": request,
"admin": admin,
"servers": servers,
"probes": probes,
"protocols": Protocol,
"app_name": request.app.state.settings.app_name,
"flash": request.query_params.get("flash"),
@@ -127,6 +129,24 @@ async def sync_server(
return RedirectResponse("/admin/servers", status_code=status.HTTP_303_SEE_OTHER)
@router.post("/servers/{server_id}/check-ssh")
async def check_ssh(
server_id: int,
db: AsyncSession = Depends(get_db),
admin=Depends(require_admin),
):
if _is_redirect(admin):
return admin
try:
await vpn_service.check_server_ssh(db, server_id)
except Exception as exc: # noqa: BLE001
return RedirectResponse(
f"/admin/servers?flash=error:{exc}",
status_code=status.HTTP_303_SEE_OTHER,
)
return RedirectResponse("/admin/servers?flash=ssh_ok", status_code=status.HTTP_303_SEE_OTHER)
@router.post("/servers/{server_id}/delete")
async def delete_server(
server_id: int,