// 관리 명령 (컨테이너 안에서): node dist/cli.js code → 게임 PC 1회용 등록 코드 (10분) import { loadConfig } from './config.js'; import { ServerStore } from './store.js'; const cmd = process.argv[2]; const dataDir = process.env.DATA_DIR || loadConfigSafe()?.dataDir || 'data'; const store = new ServerStore(dataDir); if (cmd === 'code') { const c = store.createCode('cli', Number(process.argv[3] || 10) * 60000); console.log(`등록 코드: ${c.code} (만료 ${new Date(c.expiresAt).toLocaleString('ko-KR', { timeZone: 'Asia/Seoul' })})`); } else if (cmd === 'device') { console.log(JSON.stringify(store.device(), (k, v) => (k === 'keyHash' ? undefined : v), 2)); } else if (cmd === 'unregister') { console.log(`등록 해제: ${store.removeDevices()}대 (서버를 다시 시작하면 연결도 끊긴다)`); } else { console.log('사용법: node dist/cli.js code [분] | device | unregister'); } store.flush(); function loadConfigSafe() { try { return loadConfig(); } catch { return null; } }