Remove(commented) hysteria install/uninstall APIs

This commit is contained in:
Iam54r1n4
2025-02-06 17:57:12 +00:00
parent b331218652
commit 5b1a4f2f61
2 changed files with 37 additions and 35 deletions

View File

@ -1,48 +1,49 @@
from fastapi import APIRouter, HTTPException from fastapi import APIRouter, HTTPException
from ..schema.response import DetailResponse from ..schema.response import DetailResponse
from ..schema.config.hysteria import InstallInputBody # from ..schema.config.hysteria import InstallInputBody
import cli_api import cli_api
router = APIRouter() router = APIRouter()
@router.post('/install', response_model=DetailResponse, summary='Install Hysteria2') # Change: Installing and uninstalling Hysteria2 is possible only through the CLI
async def install(body: InstallInputBody): # @router.post('/install', response_model=DetailResponse, summary='Install Hysteria2')
""" # async def install(body: InstallInputBody):
Installs Hysteria2 on the given port and uses the provided or default SNI value. # """
# Installs Hysteria2 on the given port and uses the provided or default SNI value.
Args: # Args:
body: An instance of InstallInputBody containing the new port and SNI value. # body: An instance of InstallInputBody containing the new port and SNI value.
Returns: # Returns:
A DetailResponse with a message indicating the Hysteria2 installation was successful. # A DetailResponse with a message indicating the Hysteria2 installation was successful.
Raises: # Raises:
HTTPException: if an error occurs while installing Hysteria2. # HTTPException: if an error occurs while installing Hysteria2.
""" # """
try: # try:
cli_api.install_hysteria2(body.port, body.sni) # cli_api.install_hysteria2(body.port, body.sni)
return DetailResponse(detail=f'Hysteria2 installed successfully on port {body.port} with SNI {body.sni}.') # return DetailResponse(detail=f'Hysteria2 installed successfully on port {body.port} with SNI {body.sni}.')
except Exception as e: # except Exception as e:
raise HTTPException(status_code=400, detail=f'Error: {str(e)}') # raise HTTPException(status_code=400, detail=f'Error: {str(e)}')
@router.delete('/uninstall', response_model=DetailResponse, summary='Uninstall Hysteria2') # @router.delete('/uninstall', response_model=DetailResponse, summary='Uninstall Hysteria2')
async def uninstall(): # async def uninstall():
""" # """
Uninstalls Hysteria2. # Uninstalls Hysteria2.
Returns: # Returns:
A DetailResponse with a message indicating the Hysteria2 uninstallation was successful. # A DetailResponse with a message indicating the Hysteria2 uninstallation was successful.
Raises: # Raises:
HTTPException: if an error occurs while uninstalling Hysteria2. # HTTPException: if an error occurs while uninstalling Hysteria2.
""" # """
try: # try:
cli_api.uninstall_hysteria2() # cli_api.uninstall_hysteria2()
return DetailResponse(detail='Hysteria2 uninstalled successfully.') # return DetailResponse(detail='Hysteria2 uninstalled successfully.')
except Exception as e: # except Exception as e:
raise HTTPException(status_code=400, detail=f'Error: {str(e)}') # raise HTTPException(status_code=400, detail=f'Error: {str(e)}')
@router.patch('/update', response_model=DetailResponse, summary='Update Hysteria2') @router.patch('/update', response_model=DetailResponse, summary='Update Hysteria2')

View File

@ -1,6 +1,7 @@
from pydantic import BaseModel # Change: Installing and uninstalling Hysteria2 is possible only through the CLI
# from pydantic import BaseModel
class InstallInputBody(BaseModel): # class InstallInputBody(BaseModel):
port: int # port: int
sni: str # sni: str