Previously a blocked join just dropped the socket, so the MC client showed 'Internal Exception: SocketException: Connection reset'. Now when next_state=2 (login), the proxy sends a proper Login Disconnect (0x00) packet containing a JSON chat component, and the client displays the message on its disconnect screen. - block_message added to config (default Korean message); editable in Settings UI as a textarea - build_login_disconnect() encodes (varint length)+(0x00)+(JSON str) - Status/ping (next_state=1) still silently dropped so the proxy presence is not announced to scanners - Backward-compat: load_config() backfills block_message on old files
44 lines
899 B
Python
44 lines
899 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]
|
|
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()
|