v1.3.7: 기록 관리(경기 · 경기 전후 대화 묶음, 한 번에 지우기 · zip 내보내기/받아오기) · 검토로 찾은 오류 고침
- 기록 묶음 API · zip 형식(gvr-bundle v1) · 받아오기 검사(꼭 필요한 내용이 없으면 실패, 아무것도 넣지 않음) - 사이트 기록 탭, 큰 zip 조각 중계 - 관리자 확인 %인코딩 우회, 큰 전송 중 연결 끊김, 진행 중 경기 지우기, 예전 녹음 고치기 덮어쓰기, 타임라인 끼워 넣기, 숫자 반복 줄이기, TTS 반쪽 파일 등 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -244,11 +244,19 @@ export async function buildServer(
|
||||
if (origin && origin !== cfg.publicUrl) return reply.code(403).send({ error: 'bad_origin' });
|
||||
}
|
||||
// 기록 묶음 지우기 · 받아오기는 관리자만 (보기 · zip 내려받기는 서버 멤버 누구나)
|
||||
const p = req.url.split('?')[0];
|
||||
// 주소는 풀어서(%62undles 같은 우회 막기) 소문자로 본다. 앱도 역할 헤더로 한 번 더 막는다
|
||||
let p: string;
|
||||
try {
|
||||
p = decodeURIComponent(req.url.split('?')[0]).toLowerCase();
|
||||
} catch {
|
||||
return reply.code(400).send({ error: 'bad_path' });
|
||||
}
|
||||
const bundles = p.startsWith('/api/bundles');
|
||||
if (bundles && req.method !== 'GET' && !canViewLogs(s.user.id)) return reply.code(403).send({ error: 'forbidden', message: '기록 지우기 · 받아오기는 관리자만 할 수 있습니다' });
|
||||
const admin = canViewLogs(s.user.id);
|
||||
if (bundles && p !== '/api/bundles' && p !== '/api/bundles/export' && !admin) return reply.code(403).send({ error: 'forbidden', message: '기록 지우기 · 받아오기는 관리자만 할 수 있습니다' });
|
||||
const headers: Record<string, string> = {};
|
||||
for (const k of ['range', 'content-type', 'accept']) if (req.headers[k]) headers[k] = String(req.headers[k]);
|
||||
headers['x-gvr-role'] = admin ? 'admin' : 'member';
|
||||
const body = req.body === undefined || req.body === null ? null : Buffer.isBuffer(req.body) || typeof req.body === 'string' ? req.body : JSON.stringify(req.body);
|
||||
try {
|
||||
// zip 만들기 · 받아오기는 오래 걸릴 수 있다
|
||||
|
||||
@@ -201,14 +201,21 @@ export class RelayHub {
|
||||
}, timeoutMs);
|
||||
this.pending.set(id, { resolve, reject, timer, chunks: [] });
|
||||
if (Buffer.isBuffer(body)) {
|
||||
// 바이너리 본문(zip 받아오기): 1MB 조각으로 먼저 보내고 요청을 보낸다 (앱은 한 메시지 8MB 까지)
|
||||
// 바이너리 본문(zip 받아오기): 1MB 조각으로 먼저 보내고 요청을 보낸다 (앱은 한 메시지 8MB 까지).
|
||||
// 보낼 것이 4MB 넘게 쌓이면 기다려서 ping · pong 이 너무 밀리지 않게 한다
|
||||
const idBuf = Buffer.from(id, 'utf8');
|
||||
const head = Buffer.alloc(4);
|
||||
head.writeUInt32BE(idBuf.length, 0);
|
||||
const CH = 1024 * 1024;
|
||||
for (let i = 0; i < body.length; i += CH) dev.ws.send(Buffer.concat([head, idBuf, body.subarray(i, i + CH)]), { binary: true });
|
||||
const msg: RelayToDevice = { t: 'req', id, method, path, headers, user, body: null, bin: true };
|
||||
dev.ws.send(JSON.stringify(msg));
|
||||
void (async () => {
|
||||
for (let i = 0; i < body.length; i += CH) {
|
||||
while (dev.ws.readyState === WebSocket.OPEN && dev.ws.bufferedAmount > 4 * CH) await new Promise((r) => setTimeout(r, 20));
|
||||
if (dev.ws.readyState !== WebSocket.OPEN) return;
|
||||
dev.ws.send(Buffer.concat([head, idBuf, body.subarray(i, i + CH)]), { binary: true });
|
||||
}
|
||||
const msg: RelayToDevice = { t: 'req', id, method, path, headers, user, body: null, bin: true };
|
||||
dev.ws.send(JSON.stringify(msg));
|
||||
})();
|
||||
return;
|
||||
}
|
||||
const msg: RelayToDevice = { t: 'req', id, method, path, headers, user, body };
|
||||
|
||||
Reference in New Issue
Block a user