웹소켓 도배 방지를 JSON 해석 전으로: 채팅·게임 한도를 합친 원시 한도(초당 70, 최대 240)를 파싱 전에 먼저 적용해 도배가 메시지마다 파싱 비용을 쓰지 않게(gateway.test.ts). 문서에서 지운 lastChatAt 설명 제거

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-14 09:04:07 +09:00
parent 4d1deb8346
commit 0bff06fa3e
5 changed files with 58 additions and 8 deletions

View File

@@ -91,7 +91,7 @@
| 서버 idle timeout | 40초 (Bun `idleTimeout`), 서버가 25초마다 ping 프레임 |
| 클라이언트 ping | 10초마다, 5초 안에 pong이 없으면 연결을 끊고 재연결 |
| 메시지 최대 크기 | 16KB (그림 맞히기 붓질 메시지만 32KB) |
| 속도 제한 | 연결당 토큰 버킷 초당 20개, 최대 40개. 채팅(방 채팅·게임 채팅 `act` type `chat`·`typing`)은 따로 초당 50개, 최대 200개(사람은 닿지 않는 매크로 방지용, 채팅 줄 자체의 속도 제한은 없음). 넘으면 버리고 계속 넘으면 연결 종료 |
| 속도 제한 | 연결당 토큰 버킷 초당 20개, 최대 40개. 채팅(방 채팅·게임 채팅 `act` type `chat`·`typing`)은 따로 초당 50개, 최대 200개(사람은 닿지 않는 매크로 방지용, 채팅 줄 자체의 속도 제한은 없음). 둘을 합친 원시 한도(초당 70, 최대 240)를 JSON 해석 전에 먼저 적용. 넘으면 버리고 계속 넘으면 연결 종료 |
| 압축 | permessage-deflate 사용(1KB 이상 메시지만 효과) |
| 서버 송신 버퍼 | 연결당 1MB 넘게 밀리면(느린 클라이언트) 연결을 끊음 → 재연결 시 전체 상태로 회복 |

View File

@@ -86,7 +86,7 @@
interface LiarState {
options; players: { id; left }[]; topic; word; liar; liarWord /* 바보 모드 */; order /* 1바퀴 순서 */;
phase: reveal{ready} | describe{round, turn} | discussion{ready} | vote{round 1|2, candidates, votes} | guess | ended;
descriptions: { n, round, from, text | null }[]; chat: { n, from, text, at }[]; lastChatAt;
descriptions: { n, round, from, text | null }[]; chat: { n, from, text, at }[];
events: PublicEvent[]; accused; guess; seq; final: LiarFinal | null;
}
```

View File

@@ -165,7 +165,6 @@ interface MafiaState {
lastHealTarget: PlayerId | null;
privateResults: { to: PlayerId; day: number; text: string }[]; // 경찰/영매 결과
chat: ChatMessage[]; // 서버 상태에 전부 저장, view에서 필터
lastChatAt: Record<PlayerId, number>; // 레이트 리밋
history: PublicEvent[]; // 공개 발표 기록
winner: null | 'town' | 'mafia';
}