Each allowed_domains entry can now carry its own backend {host, port}.
That lets one proxy on port 25565 serve multiple MC servers, picking
the upstream from the domain the client typed.
- proxy/main.py: ProxyState.backend_for(domain) → tuple|None,
honors per-domain backend first, falls back to top-level backend.
handle_client uses backend_for(); blocked / disabled domains
return None (and still get a Login Disconnect on join attempts).
- api/routes/{config,domains}.py: DomainBackend model + optional
backend field on create/patch. PATCH supports clear_backend=true
to drop a per-domain override and revert to default.
- frontend/Domains.jsx: full rewrite — new-domain form has host/port
inputs, table shows each row's effective backend, inline edit +
reset button per row.
- frontend/Settings.jsx: backend section relabeled "기본 백엔드 (fallback)"
- README updated with multi-server example config.
50 lines
1.0 KiB
Python
50 lines
1.0 KiB
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 DomainBackend(BaseModel):
|
|
host: str
|
|
port: int = Field(ge=1, le=65535)
|
|
|
|
|
|
class DomainEntry(BaseModel):
|
|
domain: str
|
|
enabled: bool = True
|
|
note: str = ""
|
|
backend: DomainBackend | None = None # 없으면 top-level backend 로 fallback
|
|
|
|
|
|
class FullConfig(BaseModel):
|
|
proxy: ProxyConfig
|
|
backend: BackendConfig
|
|
allowed_domains: list[DomainEntry]
|
|
block_message: str = "이 서버는 허용된 도메인에서만 접속 가능합니다."
|
|
|
|
|
|
@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()
|