feat: add API endpoint to fetch IP Limiter configuration
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
from fastapi import APIRouter, BackgroundTasks, HTTPException, UploadFile, File
|
||||
from ..schema.config.hysteria import ConfigFile, GetPortResponse, GetSniResponse
|
||||
from ..schema.response import DetailResponse, IPLimitConfig, SetupDecoyRequest, DecoyStatusResponse
|
||||
from ..schema.response import DetailResponse, IPLimitConfig, SetupDecoyRequest, DecoyStatusResponse, IPLimitConfigResponse
|
||||
from fastapi.responses import FileResponse
|
||||
import shutil
|
||||
import zipfile
|
||||
@ -335,6 +335,14 @@ async def config_ip_limit_api(config: IPLimitConfig):
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=400, detail=f'Error configuring IP Limiter: {str(e)}')
|
||||
|
||||
@router.get('/ip-limit/config', response_model=IPLimitConfigResponse, summary='Get IP Limiter Configuration')
|
||||
async def get_ip_limit_config_api():
|
||||
"""Retrieves the current IP Limiter configuration."""
|
||||
try:
|
||||
config = cli_api.get_ip_limiter_config()
|
||||
return IPLimitConfigResponse(**config)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f'Error retrieving IP Limiter configuration: {str(e)}')
|
||||
|
||||
def run_setup_decoy_background(domain: str, decoy_path: str):
|
||||
"""Function to run decoy setup in the background."""
|
||||
|
||||
@ -6,8 +6,12 @@ class DetailResponse(BaseModel):
|
||||
detail: str
|
||||
|
||||
class IPLimitConfig(BaseModel):
|
||||
block_duration: Optional[int] = None
|
||||
max_ips: Optional[int] = None
|
||||
block_duration: Optional[int] = Field(None, example=60)
|
||||
max_ips: Optional[int] = Field(None, example=1)
|
||||
|
||||
class IPLimitConfigResponse(BaseModel):
|
||||
block_duration: Optional[int] = Field(None, description="Current block duration in seconds for IP Limiter")
|
||||
max_ips: Optional[int] = Field(None, description="Current maximum IPs per user for IP Limiter")
|
||||
|
||||
class SetupDecoyRequest(BaseModel):
|
||||
domain: str = Field(..., description="Domain name associated with the web panel")
|
||||
@ -15,4 +19,4 @@ class SetupDecoyRequest(BaseModel):
|
||||
|
||||
class DecoyStatusResponse(BaseModel):
|
||||
active: bool = Field(..., description="Whether the decoy site is currently configured and active")
|
||||
path: Optional[str] = Field(None, description="The configured path for the decoy site, if active")
|
||||
path: Optional[str] = Field(None, description="The configured path for the decoy site, if active")
|
||||
Reference in New Issue
Block a user