Add api/v1/config/install-tcp-brutal|update-geo endpoints
This commit is contained in:
@ -4,6 +4,7 @@ from . import warp
|
|||||||
from . import telegram
|
from . import telegram
|
||||||
from . import normalsub
|
from . import normalsub
|
||||||
from . import singbox
|
from . import singbox
|
||||||
|
from . import misc
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@ -13,3 +14,4 @@ router.include_router(warp.router, prefix='/warp')
|
|||||||
router.include_router(telegram.router, prefix='/telegram')
|
router.include_router(telegram.router, prefix='/telegram')
|
||||||
router.include_router(normalsub.router, prefix='/normalsub')
|
router.include_router(normalsub.router, prefix='/normalsub')
|
||||||
router.include_router(singbox.router, prefix='/singbox')
|
router.include_router(singbox.router, prefix='/singbox')
|
||||||
|
router.include_router(misc.router)
|
||||||
|
|||||||
46
core/scripts/webpanel/routers/api/v1/config/misc.py
Normal file
46
core/scripts/webpanel/routers/api/v1/config/misc.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
from fastapi import APIRouter, HTTPException
|
||||||
|
from ..schema.response import DetailResponse
|
||||||
|
import cli_api
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
|
@router.get('/install-tcp-brutal', response_model=DetailResponse)
|
||||||
|
async def install_tcp_brutal():
|
||||||
|
"""
|
||||||
|
Endpoint to install TCP Brutal service.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
DetailResponse: A response object indicating the success of the installation.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
HTTPException: If an error occurs during the installation, an HTTP 400 error is raised with the error details.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
cli_api.install_tcp_brutal()
|
||||||
|
return DetailResponse(detail='TCP Brutal installed successfully.')
|
||||||
|
except Exception as e:
|
||||||
|
raise HTTPException(status_code=400, detail=f'Error: {str(e)}')
|
||||||
|
|
||||||
|
|
||||||
|
@router.get('/update-geo/{country}', response_model=DetailResponse)
|
||||||
|
async def update_geo(country: str):
|
||||||
|
"""
|
||||||
|
Endpoint to update geographic data files based on the specified country.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
country (str): The country for which to update the geo files.
|
||||||
|
Accepts 'iran', 'china', or 'russia'.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
DetailResponse: A response object indicating the success of the update operation.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
HTTPException: If an error occurs during the update process, an HTTP 400 error is raised with the error details.
|
||||||
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
cli_api.update_geo(country)
|
||||||
|
return DetailResponse(detail='Geo updated successfully.')
|
||||||
|
except Exception as e:
|
||||||
|
raise HTTPException(status_code=400, detail=f'Error: {str(e)}')
|
||||||
Reference in New Issue
Block a user