feat: send Login Disconnect with custom message on blocked join

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
This commit is contained in:
2026-05-23 17:10:49 +09:00
parent 4b0d790748
commit 75c4242365
7 changed files with 79 additions and 4 deletions

View File

@@ -21,6 +21,7 @@ DEFAULT_CONFIG = {
"allowed_domains": [
{"domain": "mc.tkrmagid.kr", "enabled": True, "note": "메인 도메인"}
],
"block_message": "이 서버는 허용된 도메인에서만 접속 가능합니다.",
}
_lock = threading.Lock()
@@ -33,7 +34,11 @@ def load_config() -> dict:
return json.loads(json.dumps(DEFAULT_CONFIG))
with _lock:
with CONFIG_PATH.open("r", encoding="utf-8") as f:
return json.load(f)
cfg = json.load(f)
# 구버전 설정 파일 호환: 누락된 최상위 키는 기본값으로 채워준다
if "block_message" not in cfg:
cfg["block_message"] = DEFAULT_CONFIG["block_message"]
return cfg
def save_config(cfg: dict) -> None: