feat: Add OBFS status API endpoint
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
from fastapi import APIRouter, BackgroundTasks, HTTPException, UploadFile, File
|
||||
from ..schema.config.hysteria import ConfigFile, GetPortResponse, GetSniResponse
|
||||
from ..schema.config.hysteria import ConfigFile, GetPortResponse, GetSniResponse, GetObfsResponse
|
||||
from ..schema.response import DetailResponse, IPLimitConfig, SetupDecoyRequest, DecoyStatusResponse, IPLimitConfigResponse
|
||||
from fastapi.responses import FileResponse
|
||||
import shutil
|
||||
@ -223,6 +223,23 @@ async def disable_obfs():
|
||||
raise HTTPException(status_code=400, detail=f'Error: {str(e)}')
|
||||
|
||||
|
||||
@router.get('/check-obfs', response_model=GetObfsResponse, summary='Check Hysteria2 OBFS Status')
|
||||
async def check_obfs():
|
||||
"""
|
||||
Checks the current status of Hysteria2 OBFS.
|
||||
|
||||
Returns:
|
||||
A GetObfsResponse containing the Hysteria2 OBFS status message (e.g., 'OBFS is active.').
|
||||
|
||||
Raises:
|
||||
HTTPException: if an error occurs while checking the Hysteria2 OBFS status.
|
||||
"""
|
||||
try:
|
||||
obfs_status_message = cli_api.check_hysteria2_obfs()
|
||||
return GetObfsResponse(obfs=obfs_status_message)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=400, detail=f'Error checking OBFS status: {str(e)}')
|
||||
|
||||
@router.get('/enable-masquerade/{domain}', response_model=DetailResponse, summary='Enable Hysteria2 masquerade')
|
||||
async def enable_masquerade(domain: str):
|
||||
"""
|
||||
|
||||
@ -18,3 +18,6 @@ class GetPortResponse(BaseModel):
|
||||
|
||||
class GetSniResponse(BaseModel):
|
||||
sni: str
|
||||
|
||||
class GetObfsResponse(BaseModel):
|
||||
obfs: str
|
||||
Reference in New Issue
Block a user