- proxy: asyncio TCP proxy with handshake parser, domain whitelist, transparent backend tunneling, SQLite logging, mtime hot reload - api: FastAPI routes for config/domains/logs/status + restart trigger - frontend: React + Vite NPM-style dashboard (dashboard/domains/logs/settings) - nginx: reverse proxy for /api -> api:8000 and / -> frontend:3000 - docker-compose: full stack with shared data volume - replace spec mc-domain-filter.md with README.md
43 lines
805 B
Python
43 lines
805 B
Python
"""전체 설정 조회/저장."""
|
|
from __future__ import annotations
|
|
|
|
from fastapi import APIRouter
|
|
from pydantic import BaseModel, Field
|
|
|
|
from config_io import load_config, save_config
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
class ProxyConfig(BaseModel):
|
|
listen_port: int = Field(ge=1, le=65535)
|
|
enabled: bool
|
|
|
|
|
|
class BackendConfig(BaseModel):
|
|
host: str
|
|
port: int = Field(ge=1, le=65535)
|
|
|
|
|
|
class DomainEntry(BaseModel):
|
|
domain: str
|
|
enabled: bool = True
|
|
note: str = ""
|
|
|
|
|
|
class FullConfig(BaseModel):
|
|
proxy: ProxyConfig
|
|
backend: BackendConfig
|
|
allowed_domains: list[DomainEntry]
|
|
|
|
|
|
@router.get("/config")
|
|
def get_config() -> dict:
|
|
return load_config()
|
|
|
|
|
|
@router.put("/config")
|
|
def put_config(body: FullConfig) -> dict:
|
|
save_config(body.model_dump())
|
|
return load_config()
|