From 917301aca585910a64f233aee0e869f6061af1f4 Mon Sep 17 00:00:00 2001 From: ReturnFI <151555003+ReturnFI@users.noreply.github.com> Date: Mon, 15 Dec 2025 19:56:00 +0000 Subject: [PATCH] feat(api): add endpoint to restart Hysteria2 service --- .../webpanel/routers/api/v1/config/hysteria.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/scripts/webpanel/routers/api/v1/config/hysteria.py b/core/scripts/webpanel/routers/api/v1/config/hysteria.py index 38dd25f..132e753 100644 --- a/core/scripts/webpanel/routers/api/v1/config/hysteria.py +++ b/core/scripts/webpanel/routers/api/v1/config/hysteria.py @@ -29,6 +29,22 @@ async def update(): except Exception as e: raise HTTPException(status_code=400, detail=f'Error: {str(e)}') +@router.post('/restart', response_model=DetailResponse, summary='Restart Hysteria2 Service') +async def restart_service(): + """ + Restarts the Hysteria2 service. + + Returns: + A DetailResponse with a message indicating the service was restarted successfully. + + Raises: + HTTPException: if an error occurs while restarting the service. + """ + try: + cli_api.restart_hysteria2() + return DetailResponse(detail='Hysteria2 service restarted successfully.') + except Exception as e: + raise HTTPException(status_code=400, detail=f'Error: {str(e)}') @router.get('/get-port', response_model=GetPortResponse, summary='Get Hysteria2 port') async def get_port_api():