Skip to content
This repository was archived by the owner on Jul 8, 2026. It is now read-only.

Commit 224a374

Browse files
committed
feat(api): update masquerade endpoints and add status check
1 parent 51d17a2 commit 224a374

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

core/scripts/webpanel/routers/api/v1/config/hysteria.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from fastapi import APIRouter, BackgroundTasks, HTTPException, UploadFile, File
2-
from ..schema.config.hysteria import ConfigFile, GetPortResponse, GetSniResponse, GetObfsResponse
2+
from ..schema.config.hysteria import ConfigFile, GetPortResponse, GetSniResponse, GetObfsResponse, GetMasqueradeStatusResponse
33
from ..schema.response import DetailResponse, IPLimitConfig, SetupDecoyRequest, DecoyStatusResponse, IPLimitConfigResponse
44
from fastapi.responses import FileResponse
55
import shutil
@@ -230,8 +230,8 @@ async def check_obfs():
230230
except Exception as e:
231231
raise HTTPException(status_code=400, detail=f'Error checking OBFS status: {str(e)}')
232232

233-
@router.get('/enable-masquerade/{domain}', response_model=DetailResponse, summary='Enable Hysteria2 masquerade')
234-
async def enable_masquerade(domain: str):
233+
@router.get('/enable-masquerade', response_model=DetailResponse, summary='Enable Hysteria2 masquerade')
234+
async def enable_masquerade():
235235
"""
236236
Enables Hysteria2 masquerade for the given domain.
237237
@@ -245,8 +245,8 @@ async def enable_masquerade(domain: str):
245245
HTTPException: if an error occurs while enabling Hysteria2 masquerade.
246246
"""
247247
try:
248-
cli_api.enable_hysteria2_masquerade(domain)
249-
return DetailResponse(detail='Hysteria2 masquerade enabled successfully.')
248+
response = cli_api.enable_hysteria2_masquerade()
249+
return DetailResponse(detail=response)
250250
except Exception as e:
251251
raise HTTPException(status_code=400, detail=f'Error: {str(e)}')
252252

@@ -268,6 +268,13 @@ async def disable_masquerade():
268268
except Exception as e:
269269
raise HTTPException(status_code=400, detail=f'Error: {str(e)}')
270270

271+
@router.get('/check-masquerade', response_model=GetMasqueradeStatusResponse, summary='Check Hysteria2 Masquerade Status')
272+
async def check_masquerade():
273+
try:
274+
status_message = cli_api.get_hysteria2_masquerade_status()
275+
return GetMasqueradeStatusResponse(status=status_message)
276+
except Exception as e:
277+
raise HTTPException(status_code=400, detail=f'Error checking Masquerade status: {str(e)}')
271278

272279
@router.get('/file', response_model=ConfigFile, summary='Get Hysteria2 configuration file')
273280
async def get_file():

core/scripts/webpanel/routers/api/v1/schema/config/hysteria.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ class GetSniResponse(BaseModel):
2020
sni: str
2121

2222
class GetObfsResponse(BaseModel):
23-
obfs: str
23+
obfs: str
24+
25+
class GetMasqueradeStatusResponse(BaseModel):
26+
status: str

0 commit comments

Comments
 (0)